Differences From Artifact [57f6f73657cc3655]:
- File
src/solver.d
- 2012-07-15 07:02:32 - part of checkin [8acc8e6c78] on branch trunk - Prioritize distant lambda. (user: kinaba) [annotate]
To Artifact [393baf841678f948]:
- File
src/solver.d
- 2012-07-15 07:11:41 - part of checkin [e8aa141dbe] on branch trunk - Make manual GUI operation faster for Solver2 by delaying plan making. (user: kinaba) [annotate]
- 2012-07-15 12:14:10 - part of checkin [e02668367d] on branch trunk - Revert redesign in the trunk. (user: kinaba) [annotate]
301 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 301 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC();
302 } 302 }
303 } 303 }
304 304
305 class Solver_2(Solver) 305 class Solver_2(Solver)
306 { 306 {
307 string plan; 307 string plan;
> 308 bool plan_broken = true;
308 309
309 Game g; 310 Game g;
310 this(in Game g) 311 this(in Game g)
311 { 312 {
312 this.g = g.clone(); 313 this.g = g.clone();
313 make_plan(g); 314 make_plan(g);
314 } 315 }
................................................................................................................................................................................
325 } 326 }
326 while(log.length>0 && log[$-1]=='W') 327 while(log.length>0 && log[$-1]=='W')
327 log.length--; 328 log.length--;
328 return tuple(s, log); 329 return tuple(s, log);
329 } 330 }
330 331
331 void make_plan(in Game g) { 332 void make_plan(in Game g) {
> 333 plan_broken = false;
332 Tuple!(Solver,string) x = run_sub_solver(g); 334 Tuple!(Solver,string) x = run_sub_solver(g);
333 plan = x[1]; 335 plan = x[1];
334 if(x[0].g.cleared) 336 if(x[0].g.cleared)
335 return; 337 return;
336 modify_plan(g, x[0].g.score); 338 modify_plan(g, x[0].g.score);
337 } 339 }
338 340
................................................................................................................................................................................
360 Game gg = g.clone(); 362 Game gg = g.clone();
361 foreach(cc;c)gg.command(cc); 363 foreach(cc;c)gg.command(cc);
362 Tuple!(Solver, string) x = run_sub_solver(gg); 364 Tuple!(Solver, string) x = run_sub_solver(gg);
363 return tuple(x[1], x[0].g.score); 365 return tuple(x[1], x[0].g.score);
364 } 366 }
365 367
366 char single_step() { 368 char single_step() {
> 369 if(plan_broken)
> 370 make_plan(g);
367 if(plan.empty) 371 if(plan.empty)
368 return 'A'; 372 return 'A';
369 char c = plan[0]; 373 char c = plan[0];
370 plan = plan[1..$]; 374 plan = plan[1..$];
371 g.command(c); 375 g.command(c);
372 return c; 376 return c;
373 } 377 }
374 378
375 void force(char c) { 379 void force(char c) {
376 g.command(c); 380 g.command(c);
> 381 if(plan.length==0 || plan[0]!=c) {
377 make_plan(g); | 382 plan = "";
> 383 plan_broken = true;
> 384 }
> 385 else
> 386 plan = plan[1..$];
378 } 387 }
379 } 388 }
380 389
381 alias Solver_2!(Solver_1) MainSolver; 390 alias Solver_2!(Solver_1) MainSolver;
382 //alias Solver_1 MainSolver; 391 //alias Solver_1 MainSolver;