Diff
Not logged in

Differences From Artifact [f6cab5c23c5cba1e]:

To Artifact [51a9d789eb377d34]:


7 7 class CUI(Solver) : GameObserver 8 8 { 9 9 this(in Game g) { solver = new Solver(g); } 10 10 Solver solver; 11 11 bool fin; 12 12 override void on_game_changed(char c, in Game g, bool finished) { fin = finished; } 13 13 } 14 + 15 +class ForSafety : GameObserver 16 +{ 17 + this(in Game g) 18 + { 19 + if(g.map.W*g.map.H <= 1000) 20 + { 21 + try { 22 + score_log ~= g.score; 23 + auto fast_solver = new FastSolver(g); 24 + foreach(_; 0..g.map.W*g.map.H) { 25 + char c = fast_solver.single_step(); 26 + if(c=='A') break; 27 + const(Game) gg = fast_solver.current_game; 28 + log ~= c; 29 + score_log ~= gg.score; 30 + if(gg.cleared || gg.dead) break; 31 + } 32 + } catch { 33 + log = null; 34 + score_log = null; 35 + } 36 + } 37 + } 38 + override void on_game_changed(char c, in Game g, bool finished) {} 39 + string log; 40 + long[] score_log; 41 +} 14 42 15 43 void main() 16 44 { 17 45 auto d = new Driver(stdin); 18 - d.addObserver!(GuardedOutput)(); 46 + auto o = d.addObserver!(GuardedOutput)(); 19 47 auto c = d.addObserver!(CUI!MainSolver)(); 48 + auto f = d.addObserver!(ForSafety)(); 49 + o.safety_data(f.log, f.score_log); 20 50 while(!c.fin) 21 51 d.command(c.solver.single_step()); 22 52 }