Differences From 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]
To Artifact [7cfac19f78d8844c]:
- File
src/solver.d
- 2012-07-14 16:04:29 - part of checkin [0c10424b3c] on branch trunk - Minor fix for danger avoidance. (user: kinaba) [annotate]
61 const(Pos)[] tgt; 61 const(Pos)[] tgt;
62 for(int y=1; y<=g.map.H; ++y) 62 for(int y=1; y<=g.map.H; ++y)
63 for(int x=1; x<=g.map.W; ++x) 63 for(int x=1; x<=g.map.W; ++x)
64 if(g.map[y,x]=='.') 64 if(g.map[y,x]=='.')
65 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='* 65 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*
66 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 66 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*')
67 tgt ~= new Pos(y,x); 67 tgt ~= new Pos(y,x);
68 cand ~= search(g, ro, tgt, death); | 68 cand ~= search(g, ro, tgt, death, true);
69 } 69 }
70 70
71 if(cand.empty) 71 if(cand.empty)
72 cand ~= tuple('W',int.max); 72 cand ~= tuple('W',int.max);
73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
74 if(c1[1] != c2[1]) 74 if(c1[1] != c2[1])
75 return c1[1] < c2[1]; 75 return c1[1] < c2[1];
................................................................................................................................................................................
106 if( cnt >= 3 && breath==1 ) { 106 if( cnt >= 3 && breath==1 ) {
107 forbidden_cell[ro.y][ro.x] = true; 107 forbidden_cell[ro.y][ro.x] = true;
108 } 108 }
109 109
110 return c; 110 return c;
111 } 111 }
112 112
113 Tuple!(char,int)[] search(in Game g, in Pos s, in Pos[] gs, string death | 113 Tuple!(char,int)[] search(in Game g, in Pos s, in Pos[] gs, string death
114 { 114 {
115 bool danger(int y, int x) 115 bool danger(int y, int x)
116 { 116 {
> 117 if(g.map[y,x] == ' ' || g.map[y,x] == 'R')
> 118 return false;
117 if(g.map[y+1,x] == '*') 119 if(g.map[y+1,x] == '*')
118 return true; 120 return true;
119 if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x 121 if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x
120 return true; 122 return true;
121 if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[ 123 if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[
122 return true; 124 return true;
123 if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1 125 if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1
................................................................................................................................................................................
222 } 224 }
223 } 225 }
224 } 226 }
225 q = q2; 227 q = q2;
226 } 228 }
227 return []; 229 return [];
228 } 230 }
229 return tryA() ~ tryB() ~ tryC(); | 231 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC();
230 } 232 }
231 } 233 }