Differences From Artifact [673d840a0e1a2769]:
- File
src/solver.d
- 2012-07-14 18:50:00 - part of checkin [faa7422a78] on branch trunk - now the robot can push the rock and turn left/right. (user: kinaba) [annotate]
To Artifact [cabc7d361baa4f5a]:
- File
src/solver.d
- 2012-07-15 02:16:47 - part of checkin [34bbd14c1a] on branch trunk - Razor searching. (user: kinaba) [annotate]
47 Tuple!(Pos, int)[] log; 47 Tuple!(Pos, int)[] log;
48 bool[][] forbidden_cell; 48 bool[][] forbidden_cell;
49 49
50 char act(const(Game) g, string death, int breath) 50 char act(const(Game) g, string death, int breath)
51 { 51 {
52 const Pos ro = g.map.robot; 52 const Pos ro = g.map.robot;
53 const Pos[] la = g.map.lambdas(); 53 const Pos[] la = g.map.lambdas();
> 54 const Pos[] ra = g.map.razors();
54 const Pos li = g.map.lift; 55 const Pos li = g.map.lift;
55 56
56 Tuple!(char,int)[] cand; 57 Tuple!(char,int)[] cand;
57 char c = 'W'; 58 char c = 'W';
58 if( la.empty ) { 59 if( la.empty ) {
59 cand = search(g, ro, [li], death); 60 cand = search(g, ro, [li], death);
60 } else { 61 } else {
61 cand ~= search(g, ro, la, death); | 62 cand ~= search(g, ro, la~ra, death);
62 } 63 }
63 64
64 // 'dig' mode 65 // 'dig' mode
65 if(cand.empty) { 66 if(cand.empty) {
66 const(Pos)[] tgt; 67 const(Pos)[] tgt;
67 for(int y=1; y<=g.map.H; ++y) 68 for(int y=1; y<=g.map.H; ++y)
68 for(int x=1; x<=g.map.W; ++x) 69 for(int x=1; x<=g.map.W; ++x)
................................................................................................................................................................................
160 } 161 }
161 if(v[y][x]) continue; 162 if(v[y][x]) continue;
162 if(y==s.y && x==s.x && i<4) { 163 if(y==s.y && x==s.x && i<4) {
163 char c = "UDRL"[i]; 164 char c = "UDRL"[i];
164 if( death.count(c) == 0 165 if( death.count(c) == 0
165 return [tuple(c, 166 return [tuple(c,
166 } else if(forbidden_cell[y][x]){ 167 } else if(forbidden_cell[y][x]){
167 } else if(g.map[y,x]==' '||g.map | 168 } else if(g.map[y,x]==' '||g.map
168 if(danger(y,x)) 169 if(danger(y,x))
169 continue; 170 continue;
170 q2 ~= new Pos(y,x); 171 q2 ~= new Pos(y,x);
171 v[y][x]=true; 172 v[y][x]=true;
172 } 173 }
173 } 174 }
174 } 175 }
................................................................................................................................................................................
200 } 201 }
201 if(v[y][x]) continue; 202 if(v[y][x]) continue;
202 if(y==s.y && x==s.x && i<4) { 203 if(y==s.y && x==s.x && i<4) {
203 char c = "UDRL"[i]; 204 char c = "UDRL"[i];
204 if( death.count(c) == 0 205 if( death.count(c) == 0
205 return [tuple(c, 206 return [tuple(c,
206 } else if(forbidden_cell[y][x]){ 207 } else if(forbidden_cell[y][x]){
207 } else if(g.map[y,x]==' '||g.map | 208 } else if(g.map[y,x]==' '||g.map
208 q2 ~= new Pos(y,x); 209 q2 ~= new Pos(y,x);
209 v[y][x]=true; 210 v[y][x]=true;
210 } 211 }
211 } 212 }
212 } 213 }
213 q = q2; 214 q = q2;
214 } 215 }
................................................................................................................................................................................
243 } 244 }
244 if(v[y][x]) continue; 245 if(v[y][x]) continue;
245 if(y==s.y && x==s.x && i<4) { 246 if(y==s.y && x==s.x && i<4) {
246 char c = "UDRL"[i]; 247 char c = "UDRL"[i];
247 if( death.count(c) == 0 248 if( death.count(c) == 0
248 return [tuple(c, 249 return [tuple(c,
249 } else if(forbidden_cell[y][x]){ 250 } else if(forbidden_cell[y][x]){
250 } else if(g.map[y,x]==' '||g.map | 251 } else if(g.map[y,x]==' '||g.map
251 q2 ~= new Pos(y,x); 252 q2 ~= new Pos(y,x);
252 v[y][x]=true; 253 v[y][x]=true;
253 } 254 }
254 } 255 }
255 } 256 }
256 q = q2; 257 q = q2;
257 } 258 }