Check-in [a0c3529225]
Not logged in
Overview
SHA1 Hash:a0c352922523d4813fbe6cb5c6880b0d3689da23
Date: 2012-07-14 23:22:32
User: kinaba
Comment:code cleanup
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 [a0394f9b9692c1eb] to [d3f73764386d7688].

2 import game; 2 import game; 3 import output; 3 import output; 4 import driver; 4 import driver; 5 import solver; 5 import solver; 6 6 7 class CUI(Solver) : GameObserver 7 class CUI(Solver) : GameObserver 8 { 8 { 9 this(const(Game) g) { < 10 solver = new Solver(g); | 9 this(in Game g) { solver = new Solver(g); } 11 } < 12 Solver solver; 10 Solver solver; 13 bool fin; 11 bool fin; 14 override void on_game_changed(char c, const(Game) g, bool finished) 12 override void on_game_changed(char c, const(Game) g, bool finished) 15 { 13 { 16 fin = finished; 14 fin = finished; 17 } 15 } 18 } 16 }

Modified src/game.d from [17dbdc662950a670] to [3baab0ddf11cca7d].

4 4 5 class Pos 5 class Pos 6 { 6 { 7 public immutable int y, x; 7 public immutable int y, x; 8 mixin DeriveCreate; 8 mixin DeriveCreate; 9 mixin DeriveCompare; 9 mixin DeriveCompare; 10 mixin DeriveShow; 10 mixin DeriveShow; 11 Pos clone() const { return new Pos(y, x); } | 11 Pos clone() const { return cast(Pos) this; } 12 12 13 @property: 13 @property: 14 Pos wait() { return this.clone(); } 14 Pos wait() { return this.clone(); } 15 Pos up() { return new Pos(y+1, x); } 15 Pos up() { return new Pos(y+1, x); } 16 Pos down() { return new Pos(y-1, x); } 16 Pos down() { return new Pos(y-1, x); } 17 Pos left() { return new Pos(y, x-1); } 17 Pos left() { return new Pos(y, x-1); } 18 Pos right() { return new Pos(y, x+1); } 18 Pos right() { return new Pos(y, x+1); } ................................................................................................................................................................................ 41 41 42 class Water 42 class Water 43 { 43 { 44 public immutable int base, pace; 44 public immutable int base, pace; 45 mixin DeriveCreate; 45 mixin DeriveCreate; 46 mixin DeriveCompare; 46 mixin DeriveCompare; 47 mixin DeriveShow; 47 mixin DeriveShow; 48 Water clone() const { return new Water(base, pace); } | 48 Water clone() const { return cast(Water)this; } 49 49 50 static load(string[string] params) 50 static load(string[string] params) 51 { 51 { 52 return new Water( 52 return new Water( 53 params.get("Water", "0").to!int(), 53 params.get("Water", "0").to!int(), 54 params.get("Flooding", "0").to!int() 54 params.get("Flooding", "0").to!int() 55 ); 55 ); ................................................................................................................................................................................ 100 100 101 char[][] data; 101 char[][] data; 102 Pos robot; 102 Pos robot; 103 Pos lift; 103 Pos lift; 104 int waterproof; 104 int waterproof; 105 105 106 Map clone() const { return new Map(this); } 106 Map clone() const { return new Map(this); } 107 this(const(Map) m) { | 107 this(in Map m) { 108 foreach(s; m.data) 108 foreach(s; m.data) 109 this.data ~= s.dup; 109 this.data ~= s.dup; 110 this.robot = m.robot.clone(); 110 this.robot = m.robot.clone(); 111 this.lift = m.lift.clone(); 111 this.lift = m.lift.clone(); 112 this.waterproof = m.waterproof; 112 this.waterproof = m.waterproof; 113 } 113 } 114 114 ................................................................................................................................................................................ 302 this(string[] raw_data, string[string] params) 302 this(string[] raw_data, string[string] params) 303 { 303 { 304 this.map = Map.load(raw_data, params); 304 this.map = Map.load(raw_data, params); 305 this.water = Water.load(params); 305 this.water = Water.load(params); 306 } 306 } 307 307 308 Game clone() const { return new Game(this); } 308 Game clone() const { return new Game(this); } 309 this(const(Game) g) { | 309 this(in Game g) { 310 map = g.map.clone(); 310 map = g.map.clone(); 311 water = g.water.clone(); 311 water = g.water.clone(); 312 turn = g.turn; 312 turn = g.turn; 313 dead = g.dead; 313 dead = g.dead; 314 lambda = g.lambda; 314 lambda = g.lambda; 315 exit_bonus = g.exit_bonus; 315 exit_bonus = g.exit_bonus; 316 under_water = g.under_water; 316 under_water = g.under_water;

Modified src/gui.d from [e56b333ba2eacac4] to [f5e549c65e603be1].

1 import dfl.all; 1 import dfl.all; 2 import util; 2 import util; 3 import game; 3 import game; 4 import driver; 4 import driver; 5 5 6 class GUI(Solver) : Form, GameObserver 6 class GUI(Solver) : Form, GameObserver 7 { 7 { 8 this(const(Game) g) | 8 this(in Game g) 9 { 9 { 10 this.solver = new Solver(g); 10 this.solver = new Solver(g); 11 setup_size(g.map.W, g.map.H); 11 setup_size(g.map.W, g.map.H); 12 setup_resources(); 12 setup_resources(); 13 setup_keyhandling(); 13 setup_keyhandling(); 14 draw(g); 14 draw(g); 15 } 15 }

Modified src/output.d from [7fa423ba9f8ebe92] to [3f9e2911ee63dc4e].

1 import util; 1 import util; 2 import game; 2 import game; 3 import driver; 3 import driver; 4 import core.stdc.signal; 4 import core.stdc.signal; 5 5 6 class NilOutput : GameObserver 6 class NilOutput : GameObserver 7 { 7 { 8 this(const(Game) g) {} | 8 this(in Game g) {} 9 override void on_game_changed(char c, const(Game) g, bool finished) {} | 9 override void on_game_changed(char c, in Game g, bool finished) {} 10 } 10 } 11 11 12 class StdOutput : GameObserver 12 class StdOutput : GameObserver 13 { 13 { 14 this(const(Game) g) {} | 14 this(in Game g) {} 15 override void on_game_changed(char c, const(Game) g, bool finished) | 15 override void on_game_changed(char c, in Game g, bool finished) 16 { 16 { 17 stdout.write(c); 17 stdout.write(c); 18 stdout.flush(); 18 stdout.flush(); 19 } 19 } 20 } 20 } 21 21 22 class GuardedOutput : GameObserver 22 class GuardedOutput : GameObserver 23 { 23 { 24 this(const(Game) g) | 24 this(in Game g) 25 { 25 { 26 setup_sigint_handling(); 26 setup_sigint_handling(); 27 ideal_log ~= g.score_if_abort_now; 27 ideal_log ~= g.score_if_abort_now; 28 } 28 } 29 29 30 override void on_game_changed(char c, const(Game) g, bool finished) | 30 override void on_game_changed(char c, in Game g, bool finished) 31 { 31 { 32 log ~= c; 32 log ~= c; 33 score_log ~= g.score; 33 score_log ~= g.score; 34 ideal_log ~= g.score_if_abort_now; 34 ideal_log ~= g.score_if_abort_now; 35 if(finished) 35 if(finished) 36 flush(); 36 flush(); 37 } 37 }