Check-in [69105bf94a]
Not logged in
Overview
SHA1 Hash:69105bf94a6e70560f92ce5163e4b5e6c913554f
Date: 2012-07-14 17:55:55
User: kinaba
Comment:Stand alone solver.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified game.d from [1928257cf62dcd18] to [7c15481493257083].

95 95 96 static Map load(string[] raw_data, string[string] params) 96 static Map load(string[] raw_data, string[string] params) 97 { 97 { 98 // TODO: choose optimal representation. 98 // TODO: choose optimal representation. 99 return new Map(raw_data, params); 99 return new Map(raw_data, params); 100 } 100 } 101 101 102 private { < 103 char[][] data; | 102 char[][] data; 104 Pos robot; | 103 Pos robot; 105 Pos lift; | 104 Pos lift; 106 int waterproof; | 105 int waterproof; 107 } | 106 108 Map clone() { return new Map(this); } 107 Map clone() { return new Map(this); } 109 this(Map m) { 108 this(Map m) { 110 foreach(s; m.data) 109 foreach(s; m.data) 111 this.data ~= s.dup; 110 this.data ~= s.dup; 112 this.robot = m.robot.clone(); 111 this.robot = m.robot.clone(); 113 this.lift = m.lift.clone(); 112 this.lift = m.lift.clone(); 114 this.waterproof = m.waterproof; 113 this.waterproof = m.waterproof; ................................................................................................................................................................................ 125 this.data[$-1][r.length..$] = ' '; 124 this.data[$-1][r.length..$] = ' '; 126 } 125 } 127 126 128 for(int y=1; y<=H; ++y) 127 for(int y=1; y<=H; ++y) 129 for(int x=1; x<=W; ++x) { 128 for(int x=1; x<=W; ++x) { 130 if(this[y,x] == 'R') 129 if(this[y,x] == 'R') 131 this.robot = new Pos(y,x); 130 this.robot = new Pos(y,x); 132 if(this[y,x] == 'L') | 131 if(this[y,x] == 'L' || this[y,x] == 'O') 133 this.lift = new Pos(y,x); 132 this.lift = new Pos(y,x); 134 } 133 } 135 134 136 this.waterproof = params.get("Waterproof", "5").to!int(); 135 this.waterproof = params.get("Waterproof", "5").to!int(); 137 } 136 } 138 137 139 const @property { 138 const @property { ................................................................................................................................................................................ 164 data[H-1-y][x] = c; 163 data[H-1-y][x] = c; 165 } 164 } 166 165 167 void opIndexAssign(char c, Pos p) 166 void opIndexAssign(char c, Pos p) 168 { 167 { 169 this[p.y, p.x] = c; 168 this[p.y, p.x] = c; 170 } 169 } > 170 > 171 Pos[] lambdas() { > 172 Pos[] ans; > 173 for(int y=1; y<=H; ++y) > 174 for(int x=1; x<=W; ++x) > 175 if(this[y,x] == '\\') > 176 ans ~= new Pos(y,x); > 177 return ans; > 178 } 171 179 172 bool cleared() 180 bool cleared() 173 { 181 { 174 for(int y=1; y<=H; ++y) 182 for(int y=1; y<=H; ++y) 175 for(int x=1; x<=W; ++x) 183 for(int x=1; x<=W; ++x) 176 if(this[y,x] == 'L' || this[y,x] == 'O') 184 if(this[y,x] == 'L' || this[y,x] == 'O') 177 return false; 185 return false;

Modified gui.d from [1dc5dff936083189] to [8bca70d55515c665].

1 import dfl.all; 1 import dfl.all; 2 import util; 2 import util; 3 import game; 3 import game; 4 import output; 4 import output; > 5 //import solver; 5 6 6 class GUI : Form 7 class GUI : Form 7 { 8 { 8 private { 9 private { 9 Game g; 10 Game g; 10 int cell; 11 int cell; 11 int turn = 0; 12 int turn = 0; ................................................................................................................................................................................ 20 noMessageFilter(); 21 noMessageFilter(); 21 this.setStyle(ControlStyles.OPAQUE, true); 22 this.setStyle(ControlStyles.OPAQUE, true); 22 this.g = g; 23 this.g = g; 23 24 24 this.paint ~= &my_paint; 25 this.paint ~= &my_paint; 25 this.keyDown ~= &my_keydown; 26 this.keyDown ~= &my_keydown; 26 27 27 const MAX_SIZE = 640; < 28 this.formBorderStyle = FormBorderStyle.FIXED_DIALOG; 28 this.formBorderStyle = FormBorderStyle.FIXED_DIALOG; 29 this.maximizeBox = false; 29 this.maximizeBox = false; 30 this.minimizeBox = false; 30 this.minimizeBox = false; 31 this.cell = MAX_SIZE / max(g.map.W, g.map.H); | 31 this.cell = min(1024/g.map.W, 640/g.map.H); 32 this.clientSize = Size(g.map.W*cell, g.map.H*cell); 32 this.clientSize = Size(g.map.W*cell, g.map.H*cell); 33 set_text(); 33 set_text(); 34 34 35 // Resources 35 // Resources 36 this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL); 36 this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL); 37 this.backColor = Color(255,255,255); 37 this.backColor = Color(255,255,255); 38 this.colors['#'] = 38 this.colors['#'] = ................................................................................................................................................................................ 92 { 92 { 93 case Keys.DOWN: g.command('D'); break; 93 case Keys.DOWN: g.command('D'); break; 94 case Keys.UP: g.command('U'); break; 94 case Keys.UP: g.command('U'); break; 95 case Keys.LEFT: g.command('L'); break; 95 case Keys.LEFT: g.command('L'); break; 96 case Keys.RIGHT: g.command('R'); break; 96 case Keys.RIGHT: g.command('R'); break; 97 case Keys.W: g.command('W'); break; 97 case Keys.W: g.command('W'); break; 98 case Keys.A: g.command('A'); break; 98 case Keys.A: g.command('A'); break; > 99 // case Keys.G: solver.act(g); break; 99 default: break; 100 default: break; 100 } 101 } 101 if(g.cleared) 102 if(g.cleared) 102 Application.exit(); 103 Application.exit(); 103 invalidate(); 104 invalidate(); 104 set_text(); 105 set_text(); 105 } 106 }