Overview
SHA1 Hash: | 45b72fc54e6d3d9a0fa45d2dfa381236e7fa1235 |
---|---|
Date: | 2012-07-15 14:56:41 |
User: | kinaba |
Comment: | Last 10 step optimization. |
Timelines: | family | ancestors | descendants | both | trunk |
Diffs: | redesign |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified score_memo.txt from [486054e680f2488a] to [51d1bbd9a3dc8805].
1 1 contest1 212! DLRDDUULLLDDL 2 -contest2 45 RRRRUA 2 +contest2 179 UURRURRLULLLDDDDRRRRUA 3 3 contest3 275! LDDDRRRRDDLLLLLDRRURURRUR 4 4 contest4 561? DRDRDRDRRLUURUUULURDDDLLLLLUURRDDRRRUUR 5 5 contest5 1281? LLUURUUURRRRRRLUULDLLULLRRDRDDDDDDUURRURRDDDLLRRUUULLLLUUUULDDDDDRDDD 6 6 contest6 737 RUULRRRRRRRRRRUUURUURUUULULLULLLLLLLLDDLDDDDDDUUUUUUUURRRDDRRRDA 7 7 contest7 867? RDRRRDDLLLDDLLRRURURRRDDRRRLLLULL 8 8 contest8 1245 RRRRRLLLLLUULLLDLLLLRRRRRURUUUUUUUUUULLLLUUULLLLRRDDDDDDLRDDDDLLRRUUULLRRUUUUUUURRRRRRRDDDDDRRRRRDRRDDDDLA 9 -contest9 1990 LRUURRRDUDUDULLLDDRRRRRRRRRUUURRRLDDRLDRRRRRRRRRRRUULLLDLULLRDDLLULULLLUULLRUULLLUULLLRRURUULDRRRRRUUUURLLLDLLRURRRRRDDDRRRRDDRRURRDDULLLLLLLUULLLDDDLLLLULLLLLLA 9 +contest9 3041 LRUURRRDUDUDULLLDDRRRRRRRRRUUURRRLDDRLDRRRRRRRRRRRUULLLDLULLRDDLLULULLLUULLRUULLLUULLLRRURUULDRRRRRUUUURLLLDLLRURRRRRDDDRRRRDDRRURRDDULLLLLLLUULLLDDDLLLLULLRULLDLLLRURRRRRRRRRUUULULLLU 10 10 contest10 2976 UUUUULLLLLLUUUUULLUULLLRDDUUUUUUURRRUDLLUUURRRDRRRRLLUURRRRLLLLLLLLLLLLLLLLLLLDDLLLDRULLLDUURLLDDDDDLRRRUULDDDDDLDDLDDDDRRRRRLLDDDRRRRULLLLURRRRRRRURRDDRDRRRRRRDDDRRUURRRLLLUA 11 11 flood1 569 LLLLDDDRRRDRDRUUULLLLLURRRRRDRRA 12 12 flood2 45 RRRRUA 13 13 flood3 716 LLUURUUURRRRRRLUULDLLULLRRDRDDDDDDA 14 14 flood4 970 DDDDLRRRRDDUUUUUUUULLLLLULLLLLLLLUUDRRURUULDRDLLLLLLDDDDLLRRRRRRUURRRRRRRRRRRRRRRUUUUUDDDDDDDDDRRRRDDDRRRRRRRUUURRLLDLLLLRRUUUULLLA 15 15 flood5 561? DRDRDRDRRLUURUUULURDDDLLLLLUURRDDRRRUUR 16 16 trampoline1 291 LDLLLLURRA
Modified src/solver.d from [ede3d182d99f2de5] to [dca9b6f10b63ba61].
293 293 } 294 294 return []; 295 295 } 296 296 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 297 297 } 298 298 } 299 299 300 -alias Solver_1 MainSolver; 300 +class Solver_2(Solver) 301 +{ 302 + string plan; 303 + 304 + Game g; 305 + this(in Game g) 306 + { 307 + this.g = g.clone(); 308 + make_plan(g); 309 + } 310 + 311 + Tuple!(Solver,string) run_sub_solver(in Game g) 312 + { 313 + string log; 314 + auto s = new Solver(g); 315 + while(!g.cleared && !g.dead && plan.length<=g.map.H*g.map.W) { 316 + char c = s.single_step(); 317 + if( c == 'A' ) 318 + break; 319 + log ~= c; 320 + } 321 + while(log.length>0 && log[$-1]=='W') 322 + log.length--; 323 + return tuple(s, log); 324 + } 325 + 326 + void make_plan(in Game g) { 327 + Tuple!(Solver,string) x = run_sub_solver(g); 328 + plan = x[1]; 329 + if(x[0].g.cleared) 330 + return; 331 + modify_plan(g, x[0].g.score); 332 + } 333 + 334 + void modify_plan(in Game ini, long unmod) 335 + { 336 + int bp = max(0, (cast(int)plan.length)-10); 337 + Game g = ini.clone(); 338 + for(int i=0; i<bp; ++i) g.command(plan[i]); 339 + 340 + Tuple!(string,long) cand = tuple(plan, unmod); 341 + for(int i=bp; i<plan.length; ++i) { 342 + foreach(char c; "UDLR") 343 + if(c != plan[i]) { 344 + Tuple!(string,long) zz = try_plan(c, g); 345 + if(cand[1]<zz[1]) 346 + cand = tuple(plan[0..i]~c~zz[0], zz[1]); 347 + } 348 + g.command(plan[i]); 349 + } 350 + plan = cand[0]; 351 + } 352 + 353 + Tuple!(string,long) try_plan(char c, in Game g) 354 + { 355 + Game gg = g.clone(); 356 + gg.command(c); 357 + Tuple!(Solver, string) x = run_sub_solver(gg); 358 + return tuple(x[1], x[0].g.score); 359 + } 360 + 361 + char single_step() { 362 + if(plan.empty) 363 + return 'A'; 364 + char c = plan[0]; 365 + plan = plan[1..$]; 366 + g.command(c); 367 + return c; 368 + } 369 + 370 + void force(char c) { 371 + g.command(c); 372 + make_plan(g); 373 + } 374 +} 375 + 376 +alias Solver_2!(Solver_1) MainSolver;