Check-in [8a59754e60]
Not logged in
Overview
SHA1 Hash:8a59754e60b008048ae6aa74f96034de43e3524e
Date: 2012-07-14 21:51:48
User: kinaba
Comment:GUI auto solver.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/cui_auto_main.d from [25b34c42eebd93c9] to [a0394f9b9692c1eb].

1 1 import util; 2 2 import game; 3 3 import output; 4 4 import driver; 5 5 import solver; 6 + 7 +class CUI(Solver) : GameObserver 8 +{ 9 + this(const(Game) g) { 10 + solver = new Solver(g); 11 + } 12 + Solver solver; 13 + bool fin; 14 + override void on_game_changed(char c, const(Game) g, bool finished) 15 + { 16 + fin = finished; 17 + } 18 +} 6 19 7 20 void main(string[] args) 8 21 { 9 22 Driver d = new Driver(stdin); 10 23 d.addObserver!(GuardedOutput)(); 11 - Solver s = d.addObserver!(Solver)(); 12 - s.run(&d.command); 24 + auto c = d.addObserver!(CUI!Solver_1)(); 25 + while(!c.fin) 26 + d.command(c.solver.single_step()); 13 27 }

Modified src/gui.d from [508aa0ef899fe75c] to [4cc6400795e7a727].

13 13 setup_keyhandling(); 14 14 draw(g); 15 15 } 16 16 17 17 private void delegate(char c) fn; 18 18 void set_fn(F)(F f) { this.fn = f; } 19 19 20 - void run() 20 + void run(bool automate = false) 21 21 { 22 + if(automate) { 23 + Timer t = new Timer; 24 + t.interval = 100; 25 + t.tick ~= (Timer sender, EventArgs ea){ 26 + fn(solver.single_step()); 27 + }; 28 + t.start(); 29 + } 22 30 Application.run(this); 23 31 } 24 32 25 33 override void on_game_changed(char c, const(Game) g, bool finished) 26 34 { 27 35 draw(g); 28 36 }