summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2019-01-10 13:48:34 +0100
committerErich Eckner <git@eckner.net>2019-01-10 13:48:34 +0100
commitc62e6f26f47282f8558550eefd768ecff302e29d (patch)
tree24cd8969eaa56972fe564036db497c08e438e2ed
parent59b84c6e478810112c88c67035c38006a01039be (diff)
downloadmarkov-master.tar.xz
try up to 10 times before starting next runHEADmaster
-rw-r--r--markov.lpr46
1 files changed, 24 insertions, 22 deletions
diff --git a/markov.lpr b/markov.lpr
index 005bf35..043e7ac 100644
--- a/markov.lpr
+++ b/markov.lpr
@@ -12,7 +12,7 @@ uses
var
wordFileName,s: string;
- count: longint;
+ count,trials: longint;
depth,i,j,current: int64;
c: char;
f: tMyStringList;
@@ -113,30 +113,32 @@ begin
// generation
while count>0 do begin
- current:=0;
- s:='';
- repeat
- current:=current * (length(i2c)+1) mod length(probabilities);
- total:=random;
- while total>0 do begin
- total:=total - probabilities[current];
- inc(current);
- end;
- dec(current);
- if current mod (length(i2c)+1) = 0 then
- break
- else
- s:=s+i2c[current mod (length(i2c)+1)];
- if length(s)>256 then begin
- dec(count);
- s:=f[0];
+ for trials:=0 to 9 do begin
+ current:=0;
+ s:='';
+ repeat
+ current:=current * (length(i2c)+1) mod length(probabilities);
+ total:=random;
+ while total>0 do begin
+ total:=total - probabilities[current];
+ inc(current);
+ end;
+ dec(current);
+ if current mod (length(i2c)+1) = 0 then
+ break
+ else
+ s:=s+i2c[current mod (length(i2c)+1)];
+ if length(s)>256 then begin
+ s:=f[0];
+ break;
+ end;
+ until false;
+ if (not f.hatZeile(s,false)) and (length(s)>3) then begin;
+ writeln(s);
break;
end;
- until false;
- if not f.hatZeile(s,false) then begin;
- writeln(s);
- dec(count);
end;
+ dec(count);
end;
f.free;