Index: score_memo.txt ================================================================== --- score_memo.txt +++ score_memo.txt @@ -1,14 +1,14 @@ contest1 212! DLRDDUULLLDDL -contest2 45 RRRRUA +contest2 179 UURRURRLULLLDDDDRRRRUA contest3 275! LDDDRRRRDDLLLLLDRRURURRUR contest4 561? DRDRDRDRRLUURUUULURDDDLLLLLUURRDDRRRUUR contest5 1281? LLUURUUURRRRRRLUULDLLULLRRDRDDDDDDUURRURRDDDLLRRUUULLLLUUUULDDDDDRDDD contest6 737 RUULRRRRRRRRRRUUURUURUUULULLULLLLLLLLDDLDDDDDDUUUUUUUURRRDDRRRDA contest7 867? RDRRRDDLLLDDLLRRURURRRDDRRRLLLULL contest8 1245 RRRRRLLLLLUULLLDLLLLRRRRRURUUUUUUUUUULLLLUUULLLLRRDDDDDDLRDDDDLLRRUUULLRRUUUUUUURRRRRRRDDDDDRRRRRDRRDDDDLA -contest9 1990 LRUURRRDUDUDULLLDDRRRRRRRRRUUURRRLDDRLDRRRRRRRRRRRUULLLDLULLRDDLLULULLLUULLRUULLLUULLLRRURUULDRRRRRUUUURLLLDLLRURRRRRDDDRRRRDDRRURRDDULLLLLLLUULLLDDDLLLLULLLLLLA +contest9 3041 LRUURRRDUDUDULLLDDRRRRRRRRRUUURRRLDDRLDRRRRRRRRRRRUULLLDLULLRDDLLULULLLUULLRUULLLUULLLRRURUULDRRRRRUUUURLLLDLLRURRRRRDDDRRRRDDRRURRDDULLLLLLLUULLLDDDLLLLULLRULLDLLLRURRRRRRRRRUUULULLLU contest10 2976 UUUUULLLLLLUUUUULLUULLLRDDUUUUUUURRRUDLLUUURRRDRRRRLLUURRRRLLLLLLLLLLLLLLLLLLLDDLLLDRULLLDUURLLDDDDDLRRRUULDDDDDLDDLDDDDRRRRRLLDDDRRRRULLLLURRRRRRRURRDDRDRRRRRRDDDRRUURRRLLLUA flood1 569 LLLLDDDRRRDRDRUUULLLLLURRRRRDRRA flood2 45 RRRRUA flood3 716 LLUURUUURRRRRRLUULDLLULLRRDRDDDDDDA flood4 970 DDDDLRRRRDDUUUUUUUULLLLLULLLLLLLLUUDRRURUULDRDLLLLLLDDDDLLRRRRRRUURRRRRRRRRRRRRRRUUUUUDDDDDDDDDRRRRDDDRRRRRRRUUURRLLDLLLLRRUUUULLLA Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -295,6 +295,82 @@ } 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