summaryrefslogtreecommitdiff
path: root/markov.lpr
diff options
context:
space:
mode:
Diffstat (limited to 'markov.lpr')
-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;