@@ -296,5 +296,81 @@ return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); } } -alias Solver_1 MainSolver; +class Solver_2(Solver) +{ + string plan; + + Game g; + this(in Game g) + { + this.g = g.clone(); + make_plan(g); + } + + Tuple!(Solver,string) run_sub_solver(in Game g) + { + string log; + auto s = new Solver(g); + while(!g.cleared && !g.dead && plan.length<=g.map.H*g.map.W) { + char c = s.single_step(); + if( c == 'A' ) + break; + log ~= c; + } + while(log.length>0 && log[$-1]=='W') + log.length--; + return tuple(s, log); + } + + void make_plan(in Game g) { + Tuple!(Solver,string) x = run_sub_solver(g); + plan = x[1]; + if(x[0].g.cleared) + return; + modify_plan(g, x[0].g.score); + } + + void modify_plan(in Game ini, long unmod) + { + int bp = max(0, (cast(int)plan.length)-10); + Game g = ini.clone(); + for(int i=0; i