Overview
SHA1 Hash: | c2c105fda0142a8354a73f5ed7bbf58b7a6727f0 |
---|---|
Date: | 2012-07-15 11:37:41 |
User: | kinaba |
Comment: | Support 'G' at any timing. |
Timelines: | family | ancestors | descendants | both | trunk |
Diffs: | redesign |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
Tags And Properties
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified src/gui.d from [b071b446f6e834b9] to [d4577900b4db97c1].
129 129 130 private: 130 private: 131 void setup_keyhandling() 131 void setup_keyhandling() 132 { 132 { 133 noMessageFilter(); 133 noMessageFilter(); 134 this.keyDown ~= &my_keydown; 134 this.keyDown ~= &my_keydown; 135 } 135 } > 136 > 137 void do_manual_command(char c) > 138 { > 139 solver.force(c); > 140 fn(c); > 141 } 136 142 137 void my_keydown(Control c, KeyEventArgs ev) 143 void my_keydown(Control c, KeyEventArgs ev) 138 { 144 { 139 switch(ev.keyCode) 145 switch(ev.keyCode) 140 { 146 { 141 case Keys.DOWN: fn('D'); break; | 147 case Keys.DOWN: do_manual_command('D'); break; 142 case Keys.UP: fn('U'); break; | 148 case Keys.UP: do_manual_command('U'); break; 143 case Keys.LEFT: fn('L'); break; | 149 case Keys.LEFT: do_manual_command('L'); break; 144 case Keys.RIGHT: fn('R'); break; | 150 case Keys.RIGHT: do_manual_command('R'); break; 145 case Keys.W: fn('W'); break; | 151 case Keys.W: do_manual_command('W'); break; 146 case Keys.S: fn('S'); break; | 152 case Keys.S: do_manual_command('S'); break; 147 case Keys.A: fn('A'); break; | 153 case Keys.A: do_manual_command('A'); break; 148 case Keys.G: fn(solver.single_step()); break; 154 case Keys.G: fn(solver.single_step()); break; 149 default: break; 155 default: break; 150 } 156 } 151 } 157 } 152 158 153 Solver solver; 159 Solver solver; 154 } 160 }
Modified src/solver.d from [df1ca9c8d7e8adb9] to [98744373e0968733].
1 import util; 1 import util; 2 import game; 2 import game; 3 3 4 class Solver_0 4 class Solver_0 5 { 5 { 6 this(const(Game) g) {} 6 this(const(Game) g) {} 7 char single_step() { return 'W'; } 7 char single_step() { return 'W'; } > 8 void force(char c) {} 8 } 9 } 9 10 10 class Solver_1 11 class Solver_1 11 { 12 { 12 int wait_count = 0; 13 int wait_count = 0; 13 int choke_count = 0; 14 int choke_count = 0; 14 15 ................................................................................................................................................................................ 22 char single_step() 23 char single_step() 23 { 24 { 24 Tuple!(string,int) de = death_move(g); 25 Tuple!(string,int) de = death_move(g); 25 char c = act(g, de[0], de[1]); 26 char c = act(g, de[0], de[1]); 26 g.command(c); 27 g.command(c); 27 return c; 28 return c; 28 } 29 } > 30 > 31 void force(char c) > 32 { > 33 g.command(c); > 34 } 29 35 30 Tuple!(string,int) death_move(const(Game) g) 36 Tuple!(string,int) death_move(const(Game) g) 31 { 37 { 32 string death; 38 string death; 33 int choice = 0; 39 int choice = 0; 34 foreach(char c; "UDLRW") { 40 foreach(char c; "UDLRW") { 35 Game gg = g.clone(); 41 Game gg = g.clone();