diff options
author | Erich Eckner <git@eckner.net> | 2019-01-10 13:48:34 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2019-01-10 13:48:34 +0100 |
commit | c62e6f26f47282f8558550eefd768ecff302e29d (patch) | |
tree | 24cd8969eaa56972fe564036db497c08e438e2ed | |
parent | 59b84c6e478810112c88c67035c38006a01039be (diff) | |
download | markov-c62e6f26f47282f8558550eefd768ecff302e29d.tar.xz |
-rw-r--r-- | markov.lpr | 46 |
1 files changed, 24 insertions, 22 deletions
@@ -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; |