3014ab5a8a 2012-07-15 kinaba: import util; 3014ab5a8a 2012-07-15 kinaba: import game; 3014ab5a8a 2012-07-15 kinaba: import output; 3014ab5a8a 2012-07-15 kinaba: import driver; 3014ab5a8a 2012-07-15 kinaba: import solver; 3014ab5a8a 2012-07-15 kinaba: 3014ab5a8a 2012-07-15 kinaba: class CUI(Solver) : GameObserver 3014ab5a8a 2012-07-15 kinaba: { 3014ab5a8a 2012-07-15 kinaba: this(in Game g) { solver = new Solver(g); } 3014ab5a8a 2012-07-15 kinaba: Solver solver; 3014ab5a8a 2012-07-15 kinaba: bool fin; 3014ab5a8a 2012-07-15 kinaba: override void on_game_changed(char c, in Game g, bool finished) { fin = finished; } 3014ab5a8a 2012-07-15 kinaba: } 3014ab5a8a 2012-07-15 kinaba: 3014ab5a8a 2012-07-15 kinaba: void main() 3014ab5a8a 2012-07-15 kinaba: { 3014ab5a8a 2012-07-15 kinaba: auto d = new Driver(stdin); 3014ab5a8a 2012-07-15 kinaba: d.addObserver!(GuardedOutput)(); 3014ab5a8a 2012-07-15 kinaba: auto c = d.addObserver!(CUI!MainSolver)(); 3014ab5a8a 2012-07-15 kinaba: while(!c.fin) 3014ab5a8a 2012-07-15 kinaba: d.command(c.solver.single_step()); 3014ab5a8a 2012-07-15 kinaba: }