Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -8,10 +8,11 @@ } class Solver_1 { int wait_count = 0; + int choke_count = 0; Game g; this(const(Game) g) { this.g = g.clone(); @@ -70,12 +71,14 @@ ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') tgt ~= new Pos(y,x); cand ~= search(g, ro, tgt, death, true); } - if(cand.empty) + if(cand.empty) { + choke_count++; cand ~= tuple('W',int.max); + } sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ if(c1[1] != c2[1]) return c1[1] < c2[1]; return c1[0] < c2[0]; })(cand); @@ -87,17 +90,16 @@ c=live; break; } } - if(c=='W') { + if(c == 'W') wait_count++; - if(wait_count > g.map.H) - c = 'A'; - } else wait_count = 0; + if(choke_count >= g.map.H) + c = 'A'; bool[char] choice; foreach(t; cand) choice[t[0]] = true; log ~= tuple(ro.clone(), cast(int)choice.length);