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