Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -209,31 +209,44 @@ tgt ~= new Pos(y,x); } cand ~= search(g, ro, tgt, death, true); } } + + // 'horo-push' mode + if(cand.empty) { + Pos[] horo = g.map.objects('@'); + Pos[] tgt; + foreach(p; horo) + if((g.map[p.y,p.x-1]==' '||g.map[p.y,p.x-1]=='R')&& + (g.map[p.y,p.x+1]==' '||g.map[p.y,p.x+1]=='R') + ||(g.map[p.y-1,p.x]==' '||g.map[p.y-1,p.x]=='R')) + tgt ~= p; + + for(int y=1; y<=g.map.H; ++y) + for(int x=1; x<=g.map.W; ++x) + if(g.map[y,x]=='.') + if(is_rocky(g.map[y+1,x])||is_rocky(g.map[y+1,x-1])||is_rocky(g.map[y+1,x+1]) + ||is_rocky(g.map[y,x+1])||is_rocky(g.map[y,x-1])) + tgt ~= new Pos(y,x); + + if(!tgt.empty) + cand ~= search(g, ro, tgt, death, true); + } // 'dig' mode if(cand.empty) { - const(Pos)[] tgt; + Pos[] tgt; for(int y=1; y<=g.map.H; ++y) for(int x=1; x<=g.map.W; ++x) if(g.map[y,x]=='.') if(is_rocky(g.map[y+1,x])||is_rocky(g.map[y+1,x-1])||is_rocky(g.map[y+1,x+1]) ||is_rocky(g.map[y,x+1])||is_rocky(g.map[y,x-1])) tgt ~= new Pos(y,x); cand ~= search(g, ro, tgt, death, true); } - // 'horo-push' mode - if(cand.empty) { - Pos[] horo = g.map.objects('@'); - if(!horo.empty) { - cand ~= search(g, ro, horo, death, true); - } - } - if(cand.empty) { choke_count++; cand ~= tuple('W',int.max); } sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){