Diff
Not logged in

Differences From Artifact [6402a11e444d2d1e]:

To Artifact [8291f785bb7f35e6]:


1 import std.algorithm; 1 import std.algorithm; 2 import std.array; 2 import std.array; 3 import std.conv; 3 import std.conv; 4 import std.stdio; 4 import std.stdio; 5 import std.string; 5 import std.string; > 6 import std.typecons; 6 import dfl.all; 7 import dfl.all; 7 8 8 class Map 9 class Map 9 { 10 { 10 private char[][] data; 11 private char[][] data; 11 bool dead = false; 12 bool dead = false; 12 bool cleared = false; 13 bool cleared = false; ................................................................................................................................................................................ 190 oy=y, ox=x; 191 oy=y, ox=x; 191 if(ly.length==0) 192 if(ly.length==0) 192 return goal(sy,sx,oy,ox); 193 return goal(sy,sx,oy,ox); 193 return wait(); 194 return wait(); 194 } 195 } 195 int goal(int sy, int sx, int oy, int ox) 196 int goal(int sy, int sx, int oy, int ox) 196 { 197 { > 198 alias Tuple!(int,"y",int,"x") Pt; > 199 Pt[] q = [Pt(oy,ox)]; > 200 while(q.length) { > 201 Pt[] q2; > 202 foreach(p; q) { > 203 > 204 int[] dy=[-1,+1,0,0]; > 205 int[] dx=[0,0,-1,+1]; > 206 for(int i=0; i<4; ++i) { > 207 int y = p.y+dy[i]; > 208 int x = p.x+dx[i]; > 209 if(y==sy && x==sx) { > 210 if(i==0) return command_D(); > 211 if(i==1) return command_U(); > 212 if(i==2) return command_R(); > 213 if(i==3) return command_L(); > 214 } else if(data[y][x]==' ') { > 215 q2 ~= Pt(y,x); > 216 } else if(data[y][x]=='.' && data[y-1][x > 217 q2 ~= Pt(y,x); > 218 } > 219 } > 220 } > 221 q = q2; > 222 } > 223 q = [Pt(oy,ox)]; > 224 while(q.length) { > 225 Pt[] q2; > 226 foreach(p; q) { > 227 > 228 int[] dy=[-1,+1,0,0]; > 229 int[] dx=[0,0,-1,+1]; > 230 for(int i=0; i<4; ++i) { > 231 int y = p.y+dy[i]; > 232 int x = p.x+dx[i]; > 233 if(y==sy && x==sx) { > 234 if(i==0) return command_D(); > 235 if(i==1) return command_U(); > 236 if(i==2) return command_R(); > 237 if(i==3) return command_L(); > 238 } else if(data[y][x]==' ') { > 239 q2 ~= Pt(y,x); > 240 } else if(data[y][x]=='.'/* && data[y-1] > 241 q2 ~= Pt(y,x); > 242 } > 243 } > 244 } > 245 q = q2; > 246 } 197 return wait(); | 247 return abort(); 198 } 248 } 199 } 249 } 200 250 201 class MyForm : Form 251 class MyForm : Form 202 { 252 { 203 Map m; 253 Map m; 204 int score; 254 int score;