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

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

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