Differences From Artifact [4f413ed4f5088aec]:
- File
src/solver.d
- 2012-07-14 15:43:48 - part of checkin [901abf2f53] on branch trunk - optimized multiple lambda target. (user: kinaba) [annotate]
To Artifact [dca756d0b000be21]:
- File
src/solver.d
- 2012-07-14 15:47:12 - part of checkin [68c41bdbe0] on branch trunk - Hori-Susumu kun. (user: kinaba) [annotate]
53 53 Tuple!(char,int)[] cand;
54 54 char c = 'W';
55 55 if( la.empty ) {
56 56 cand = search(g, ro, [li], death);
57 57 } else {
58 58 cand ~= search(g, ro, la, death);
59 59 }
60 - cand ~= tuple('W',int.max);
60 + if(cand.empty) {
61 + const(Pos)[] tgt;
62 + for(int y=1; y<=g.map.H; ++y)
63 + for(int x=1; x<=g.map.W; ++x)
64 + if(g.map[y,x]=='.')
65 + if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*'||g.map[y+1,x+1]=='*'
66 + ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*')
67 + tgt ~= new Pos(y,x);
68 + cand ~= search(g, ro, tgt, death);
69 + }
70 +
71 + if(cand.empty)
72 + cand ~= tuple('W',int.max);
61 73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
62 74 if(c1[1] != c2[1])
63 75 return c1[1] < c2[1];
64 76 return c1[0] < c2[0];
65 77 })(cand);
66 78 c = cand[0][0];
67 79