Diff
Not logged in

Differences From Artifact [4262c5e337ee629c]:

To Artifact [6402a11e444d2d1e]:


62 62 if(i) result ~= '\n'; 63 63 result ~= s.idup; 64 64 } 65 65 return result; 66 66 } 67 67 } 68 68 69 - int command_R() { return move(0, +1); } 70 - int command_L() { return move(0, -1); } 71 - int command_U() { return move(-1, 0); } 72 - int command_D() { return move(+1, 0); } 73 - int wait() { if(dead)return 0; update(); return -1; } 74 - int abort() { if(dead)return 0; cleared=true; return gained*25; } 69 + int command_R() { if(dead)return 0; write("R"); return move(0, +1); } 70 + int command_L() { if(dead)return 0; write("L"); return move(0, -1); } 71 + int command_U() { if(dead)return 0; write("U"); return move(-1, 0); } 72 + int command_D() { if(dead)return 0; write("D"); return move(+1, 0); } 73 + int wait() { if(dead)return 0; update(); write("W"); return -1; } 74 + int abort() { if(dead)return 0; cleared=true; write("A"); return gained*25; } 75 75 76 76 int move(int dy, int dx) { 77 77 foreach(y,s; data) 78 78 foreach(x,c; s) 79 79 if(c == 'R') 80 80 return move(dy, dx, y, x); 81 81 assert(false); ................................................................................ 190 190 oy=y, ox=x; 191 191 if(ly.length==0) 192 192 return goal(sy,sx,oy,ox); 193 193 return wait(); 194 194 } 195 195 int goal(int sy, int sx, int oy, int ox) 196 196 { 197 + return wait(); 197 198 } 198 199 } 199 200 200 201 class MyForm : Form 201 202 { 202 203 Map m; 203 204 int score; ................................................................................ 249 250 } 250 251 void myKey(Control c, KeyEventArgs ev) 251 252 { 252 253 switch(ev.keyCode) 253 254 { 254 255 case Keys.DOWN: 255 256 score += m.command_D(); 256 - write("D"); 257 257 stdout.flush(); 258 258 break; 259 259 case Keys.UP: 260 260 score += m.command_U(); 261 - write("U"); 262 261 stdout.flush(); 263 262 break; 264 263 case Keys.LEFT: 265 264 score += m.command_L(); 266 - write("L"); 267 265 stdout.flush(); 268 266 break; 269 267 case Keys.RIGHT: 270 268 score += m.command_R(); 271 - write("R"); 272 269 stdout.flush(); 273 270 break; 274 271 case Keys.W: 275 272 score += m.wait(); 276 - write("W"); 277 273 stdout.flush(); 278 274 break; 279 275 case Keys.A: 280 276 score += m.abort(); 281 - write("A"); 282 277 stdout.flush(); 283 278 break; 284 279 case Keys.G: 285 280 score += m.clever(); 286 - write("_"); 287 281 stdout.flush(); 288 282 break; 289 283 default: 290 284 break; 291 285 } 292 286 if(m.cleared) { 293 287 writeln();