Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -316,11 +316,11 @@ } class Solver_2(SubSolver) : Solver { // Parameters. - static const PredictFuture = 10; + int PredictFuture = 10; const string[] RandomChoicePattern; // PF*RCP exhaustive search for RL steps const ReplanLength = 400; // O(PF*RCP*RL*SubSolver.single_step) Game current_game; SubSolver sub_solver; @@ -328,10 +328,11 @@ enum {Tentative, Tentative_Stuck, Fixed}; string plan; int plan_state; int replan_limit; bool lambda_getter; + int clear_improvement = 3; this(in Game g) { current_game = g.clone(); plan = ""; @@ -344,10 +345,15 @@ "RU","RD","RL","RR","UUU","UUUU","UUUUU"]; else if(g.map.W*g.map.H <= 4096) RandomChoicePattern = ["UUU","U","D","L","R","UD","DU","LR","RL"]; else RandomChoicePattern = ["U","D","L","R"]; + + if(g.map.W*g.map.H <= 400) + PredictFuture = 20; + else + PredictFuture = 10; } char single_step() { if(current_game.dead || current_game.cleared) @@ -412,10 +418,11 @@ { stderr.writeln("replan!"); // Try to replace every step of the plan by another move. Game g = current_game.clone(); Tuple!(SubSolver, string, int) cand = tuple(sub_solver, plan, Tentative_Stuck); + int insertion_point = plan.length; writeln(cand, " ", cand[0].g.map.collected_lambda); bool tiebreak_by_turn = false; for(int i=0; i0) { + sub_solver = cand[0]; + plan = cand[1]; + plan_state = Tentative_Stuck; + replan_limit = (plan.length - insertion_point); + lambda_getter = current_game.map.collected_lambda < cand[0].g.map.collected_lambda; + } else { + sub_solver = cand[0]; + plan = cand[1]; + plan_state = (plan.length < PredictFuture ? Fixed : cand[2]); + replan_limit = tiebreak_by_turn ? min(PredictFuture, plan.length/2) : PredictFuture; + lambda_getter = current_game.map.collected_lambda < cand[0].g.map.collected_lambda; + } } Tuple!(SubSolver, string, int) try_plan(in Game g, string prefix) { SubSolver s = new SubSolver(g);