Differences From Artifact [25a73167930e3586]:
- File
src/solver.d
- 2012-07-16 05:02:08 - part of checkin [b2ea244589] on branch trunk - Switcher implemented. (user: kinaba) [annotate]
To Artifact [ec50c689624301b2]:
- File
src/solver.d
- 2012-07-16 05:26:29 - part of checkin [6c02dd0cf0] on branch trunk - Minor change of BFS ordering. (user: kinaba) [annotate]
298 if(!danger(p.y,p.x)) 298 if(!danger(p.y,p.x))
299 q ~= p; 299 q ~= p;
300 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 300 bool[][] v = new bool[][](g.map.H+2, g.map.W+2);
301 foreach(p; q) v[p.y][p.x]=true; 301 foreach(p; q) v[p.y][p.x]=true;
302 for(int step=1; q.length; ++step) { 302 for(int step=1; q.length; ++step) {
303 Pos[] q2; 303 Pos[] q2;
304 foreach(p; q) { 304 foreach(p; q) {
305 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; | 305 int[] yyy=[p.y-1,p.y,p.y,p.y+1];
306 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; | 306 int[] xxx=[p.x,p.x-1,p.x+1,p.x];
> 307 string sss="URLD";
307 for(int i=0; i<yyy.length; ++i) { 308 for(int i=0; i<yyy.length; ++i) {
308 int y = yyy[i]; 309 int y = yyy[i];
309 int x = xxx[i]; 310 int x = xxx[i];
310 if('1'<=g.map[y,x]&&g.map[y,x]<= 311 if('1'<=g.map[y,x]&&g.map[y,x]<=
311 foreach(ppp; g.tr.source 312 foreach(ppp; g.tr.source
312 yyy ~= ppp.y; 313 yyy ~= ppp.y;
313 xxx ~= ppp.x; 314 xxx ~= ppp.x;
314 } 315 }
315 continue; 316 continue;
316 } 317 }
317 if(v[y][x]) continue; 318 if(v[y][x]) continue;
318 if(y==s.y && x==s.x && i<4) { 319 if(y==s.y && x==s.x && i<4) {
319 char c = "UDRL"[i]; | 320 char c = sss[i];
320 if( death.count(c) == 0 321 if( death.count(c) == 0
321 return [tuple(c, 322 return [tuple(c,
322 } else if(forbidden_cell[y][x]){ 323 } else if(forbidden_cell[y][x]){
323 } else if(g.map[y,x]==' '||g.map 324 } else if(g.map[y,x]==' '||g.map
324 if(danger(y,x)) 325 if(danger(y,x))
325 continue; 326 continue;
326 q2 ~= new Pos(y,x); 327 q2 ~= new Pos(y,x);
................................................................................................................................................................................
338 const(Pos)[] q; 339 const(Pos)[] q;
339 foreach(p; gs) q ~= p; 340 foreach(p; gs) q ~= p;
340 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 341 bool[][] v = new bool[][](g.map.H+2, g.map.W+2);
341 foreach(p; q) v[p.y][p.x]=true; 342 foreach(p; q) v[p.y][p.x]=true;
342 for(int step=10; q.length; ++step) { 343 for(int step=10; q.length; ++step) {
343 Pos[] q2; 344 Pos[] q2;
344 foreach(p; q) { 345 foreach(p; q) {
345 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; | 346 int[] yyy=[p.y-1,p.y,p.y,p.y+1];
346 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; | 347 int[] xxx=[p.x,p.x-1,p.x+1,p.x];
> 348 string sss="URLD";
347 for(int i=0; i<yyy.length; ++i) { 349 for(int i=0; i<yyy.length; ++i) {
348 int y = yyy[i]; 350 int y = yyy[i];
349 int x = xxx[i]; 351 int x = xxx[i];
350 if('1'<=g.map[y,x]&&g.map[y,x]<= 352 if('1'<=g.map[y,x]&&g.map[y,x]<=
351 foreach(ppp; g.tr.source 353 foreach(ppp; g.tr.source
352 yyy ~= ppp.y; 354 yyy ~= ppp.y;
353 xxx ~= ppp.x; 355 xxx ~= ppp.x;
354 } 356 }
355 continue; 357 continue;
356 } 358 }
357 if(v[y][x]) continue; 359 if(v[y][x]) continue;
358 if(y==s.y && x==s.x && i<4) { 360 if(y==s.y && x==s.x && i<4) {
359 char c = "UDRL"[i]; | 361 char c = sss[i];
360 if( death.count(c) == 0 362 if( death.count(c) == 0
361 return [tuple(c, 363 return [tuple(c,
362 } else if(forbidden_cell[y][x]){ 364 } else if(forbidden_cell[y][x]){
363 } else if(g.map[y,x]==' '||g.map 365 } else if(g.map[y,x]==' '||g.map
364 q2 ~= new Pos(y,x); 366 q2 ~= new Pos(y,x);
365 v[y][x]=true; 367 v[y][x]=true;
366 } 368 }
................................................................................................................................................................................
376 const(Pos)[] q; 378 const(Pos)[] q;
377 foreach(p; gs) q ~= p; 379 foreach(p; gs) q ~= p;
378 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 380 bool[][] v = new bool[][](g.map.H+2, g.map.W+2);
379 foreach(p; q) v[p.y][p.x]=true; 381 foreach(p; q) v[p.y][p.x]=true;
380 for(int step=20; q.length; ++step) { 382 for(int step=20; q.length; ++step) {
381 Pos[] q2; 383 Pos[] q2;
382 foreach(p; q) { 384 foreach(p; q) {
383 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; | 385 int[] yyy=[p.y-1,p.y,p.y,p.y+1];
384 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; | 386 int[] xxx=[p.x,p.x-1,p.x+1,p.x];
> 387 string sss="URLD";
385 for(int i=0; i<yyy.length; ++i) { 388 for(int i=0; i<yyy.length; ++i) {
386 int y = yyy[i]; 389 int y = yyy[i];
387 int x = xxx[i]; 390 int x = xxx[i];
388 if(is_rocky(g.map[p])) { 391 if(is_rocky(g.map[p])) {
389 if(i>=4)continue; 392 if(i>=4)continue;
390 if(y!=p.y)continue; 393 if(y!=p.y)continue;
391 if(g.map[y,p.x+(p.x-x)]! 394 if(g.map[y,p.x+(p.x-x)]!
................................................................................................................................................................................
395 yyy ~= ppp.y; 398 yyy ~= ppp.y;
396 xxx ~= ppp.x; 399 xxx ~= ppp.x;
397 } 400 }
398 continue; 401 continue;
399 } 402 }
400 if(v[y][x]) continue; 403 if(v[y][x]) continue;
401 if(y==s.y && x==s.x && i<4) { 404 if(y==s.y && x==s.x && i<4) {
402 char c = "UDRL"[i]; | 405 char c = sss[i];
403 if( death.count(c) == 0 406 if( death.count(c) == 0
404 return [tuple(c, 407 return [tuple(c,
405 } else if(forbidden_cell[y][x]){ 408 } else if(forbidden_cell[y][x]){
406 } else if(g.map[y,x]==' '||g.map 409 } else if(g.map[y,x]==' '||g.map
407 q2 ~= new Pos(y,x); 410 q2 ~= new Pos(y,x);
408 v[y][x]=true; 411 v[y][x]=true;
409 } 412 }
................................................................................................................................................................................
719 } 722 }
720 char single_step() { return sub_solver.single_step(); } 723 char single_step() { return sub_solver.single_step(); }
721 void force(char c) { return sub_solver.force(c); } 724 void force(char c) { return sub_solver.force(c); }
722 725
723 private Solver sub_solver; 726 private Solver sub_solver;
724 } 727 }
725 728
726 alias Switcher MainSolver; | 729 //alias Switcher MainSolver;
727 //alias 侵掠如火!(疾如風) MainSolver; 730 //alias 侵掠如火!(疾如風) MainSolver;
728 //alias 侵掠如火!(徐如林) MainSolver; | 731 alias 侵掠如火!(徐如林) MainSolver;
729 //alias 疾如風 MainSolver; 732 //alias 疾如風 MainSolver;
730 //alias 徐如林 MainSolver; 733 //alias 徐如林 MainSolver;
731 //alias 不動如山 MainSolver; 734 //alias 不動如山 MainSolver;