From c62e6f26f47282f8558550eefd768ecff302e29d Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Thu, 10 Jan 2019 13:48:34 +0100 Subject: try up to 10 times before starting next run --- markov.lpr | 46 ++++++++++++++++++++++++---------------------- 1 file 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; -- cgit v1.2.3-70-g09d2