Differences From Artifact [b158ce3255b33a97]:
- File
src/solver.d
- 2012-07-16 07:16:59 - part of checkin [70423f9ad9] on branch trunk - horock-push mode. (user: kinaba) [annotate]
To Artifact [a41fda48c5fe0806]:
- File
src/solver.d
- 2012-07-16 07:24:55 - part of checkin [9fd05a2326] on branch trunk - better integrated horo-push. (user: kinaba) [annotate]
207 his++; 207 his++;
208 if(his>=2) 208 if(his>=2)
209 tgt ~= new Pos(y,x); 209 tgt ~= new Pos(y,x);
210 } 210 }
211 cand ~= search(g, ro, tgt, death, true); 211 cand ~= search(g, ro, tgt, death, true);
212 } 212 }
213 } 213 }
> 214
> 215 // 'horo-push' mode
> 216 if(cand.empty) {
> 217 Pos[] horo = g.map.objects('@');
> 218 Pos[] tgt;
> 219 foreach(p; horo)
> 220 if((g.map[p.y,p.x-1]==' '||g.map[p.y,p.x-1]=='R'
> 221 (g.map[p.y,p.x+1]==' '||g.map[p.y,p.x+1]=='R'
> 222 ||(g.map[p.y-1,p.x]==' '||g.map[p.y-1,p.x]=='R'
> 223 tgt ~= p;
> 224
> 225 for(int y=1; y<=g.map.H; ++y)
> 226 for(int x=1; x<=g.map.W; ++x)
> 227 if(g.map[y,x]=='.')
> 228 if(is_rocky(g.map[y+1,x])||is_rocky(g.ma
> 229 ||is_rocky(g.map[y,x+1])||is_rocky(g.ma
> 230 tgt ~= new Pos(y,x);
> 231
> 232 if(!tgt.empty)
> 233 cand ~= search(g, ro, tgt, death, true);
> 234 }
214 235
215 // 'dig' mode 236 // 'dig' mode
216 if(cand.empty) { 237 if(cand.empty) {
217 const(Pos)[] tgt; | 238 Pos[] tgt;
218 for(int y=1; y<=g.map.H; ++y) 239 for(int y=1; y<=g.map.H; ++y)
219 for(int x=1; x<=g.map.W; ++x) 240 for(int x=1; x<=g.map.W; ++x)
220 if(g.map[y,x]=='.') 241 if(g.map[y,x]=='.')
221 if(is_rocky(g.map[y+1,x])||is_rocky(g.ma 242 if(is_rocky(g.map[y+1,x])||is_rocky(g.ma
222 ||is_rocky(g.map[y,x+1])||is_rocky(g.ma 243 ||is_rocky(g.map[y,x+1])||is_rocky(g.ma
223 tgt ~= new Pos(y,x); 244 tgt ~= new Pos(y,x);
224 cand ~= search(g, ro, tgt, death, true); 245 cand ~= search(g, ro, tgt, death, true);
225 } 246 }
226 247
227 // 'horo-push' mode <
228 if(cand.empty) { <
229 Pos[] horo = g.map.objects('@'); <
230 if(!horo.empty) { <
231 cand ~= search(g, ro, horo, death, true); <
232 } <
233 } <
234 <
235 if(cand.empty) { 248 if(cand.empty) {
236 choke_count++; 249 choke_count++;
237 cand ~= tuple('W',int.max); 250 cand ~= tuple('W',int.max);
238 } 251 }
239 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 252 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
240 if(c1[1] != c2[1]) 253 if(c1[1] != c2[1])
241 return c1[1] < c2[1]; 254 return c1[1] < c2[1];