Check-in [3a08e528e7]
Not logged in
Overview
SHA1 Hash:3a08e528e71ee872f10fae14328efc3e2766480c
Date: 2012-07-15 11:11:16
User: kinaba
Comment:Using razor.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/game.d from [89ef01bfcc63d3cd] to [09842c914b3d99f0].

236 236 if(this[y,x] == 'L' || this[y,x] == 'O') 237 237 return false; 238 238 return true; 239 239 } 240 240 241 241 Tuple!(int,bool) command(char c, int turn) 242 242 { 243 + assert( this[robot] == 'R' ); 243 244 if(c=='R') return move( 0, +1, turn); 244 245 if(c=='L') return move( 0, -1, turn); 245 246 if(c=='U') return move(+1, 0, turn); 246 247 if(c=='D') return move(-1, 0, turn); 247 248 if(c=='W') return move( 0, 0, turn); 249 + if(c=='S') return use_razor(turn); 248 250 assert(false); 249 251 } 252 + 253 + Tuple!(int, bool) use_razor(int turn) 254 + { 255 + if(razor) { 256 + razor--; 257 + for(int dy=-1; dy<=+1; ++dy) 258 + for(int dx=-1; dx<=+1; ++dx) 259 + if(this[robot.y+dy,robot.x+dx] == 'W') 260 + this[robot.y+dy,robot.x+dx] = ' '; 261 + } 262 + 263 + bool dead = update(turn); 264 + return tuple(0,dead); 265 + } 250 266 251 267 Tuple!(int, bool) move(int dy, int dx, int turn) 252 268 { 253 269 int y = robot.y; 254 270 int x = robot.x; 255 - assert( this[robot] == 'R' ); 256 271 int lambda = 0; 257 - bool dead = false; 258 272 if( '\\' == this[y+dy,x+dx] ) 259 273 lambda++; 260 274 if( '!' == this[y+dy,x+dx] ) 261 275 razor++; 262 276 if( " \\!.O".count(this[y+dy,x+dx])==1 ) { 263 277 this[y,x]=' '; 264 278 this[y+dy,x+dx]='R'; ................................................................................ 272 286 this[y,x]=' '; 273 287 Pos tp = tr_target[this[y+dy,x+dx]]; 274 288 foreach(p; tr_source[this[tp]]) 275 289 this[p] = ' '; 276 290 this[tp] = 'R'; 277 291 robot = tp; 278 292 } 279 - if( update(turn) ) 280 - dead = true; 293 + bool dead = update(turn); 281 294 return tuple(lambda,dead); 282 295 } 283 296 284 297 bool update(int turn) 285 298 { 286 299 bool dead = false; 287 300

Modified src/gui.d from [3be06eef4f2a58fa] to [b071b446f6e834b9].

139 139 switch(ev.keyCode) 140 140 { 141 141 case Keys.DOWN: fn('D'); break; 142 142 case Keys.UP: fn('U'); break; 143 143 case Keys.LEFT: fn('L'); break; 144 144 case Keys.RIGHT: fn('R'); break; 145 145 case Keys.W: fn('W'); break; 146 + case Keys.S: fn('S'); break; 146 147 case Keys.A: fn('A'); break; 147 148 case Keys.G: fn(solver.single_step()); break; 148 149 default: break; 149 150 } 150 151 } 151 152 152 153 Solver solver; 153 154 }