Check-in [34bbd14c1a]
Not logged in
Overview
SHA1 Hash:34bbd14c1a29238a314fee2e914e36e376544a6f
Date: 2012-07-15 11:16:47
User: kinaba
Comment:Razor searching.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/game.d from [09842c914b3d99f0] to [5d6b45c159e125db].

216 216 } 217 217 218 218 void opIndexAssign(char c, in Pos p) 219 219 { 220 220 this[p.y, p.x] = c; 221 221 } 222 222 223 - Pos[] lambdas() const { 223 + Pos[] objects(char c) const { 224 224 Pos[] ans; 225 225 for(int y=1; y<=H; ++y) 226 226 for(int x=1; x<=W; ++x) 227 - if(this[y,x] == '\\') 227 + if(this[y,x] == c) 228 228 ans ~= new Pos(y,x); 229 229 return ans; 230 230 } 231 231 232 + Pos[] razors() const { return objects('!'); } 233 + Pos[] lambdas() const { return objects('\\'); } 234 + 232 235 bool cleared() const 233 236 { 234 237 for(int y=1; y<=H; ++y) 235 238 for(int x=1; x<=W; ++x) 236 239 if(this[y,x] == 'L' || this[y,x] == 'O') 237 240 return false; 238 241 return true;

Modified src/solver.d from [673d840a0e1a2769] to [cabc7d361baa4f5a].

47 47 Tuple!(Pos, int)[] log; 48 48 bool[][] forbidden_cell; 49 49 50 50 char act(const(Game) g, string death, int breath) 51 51 { 52 52 const Pos ro = g.map.robot; 53 53 const Pos[] la = g.map.lambdas(); 54 + const Pos[] ra = g.map.razors(); 54 55 const Pos li = g.map.lift; 55 56 56 57 Tuple!(char,int)[] cand; 57 58 char c = 'W'; 58 59 if( la.empty ) { 59 60 cand = search(g, ro, [li], death); 60 61 } else { 61 - cand ~= search(g, ro, la, death); 62 + cand ~= search(g, ro, la~ra, death); 62 63 } 63 64 64 65 // 'dig' mode 65 66 if(cand.empty) { 66 67 const(Pos)[] tgt; 67 68 for(int y=1; y<=g.map.H; ++y) 68 69 for(int x=1; x<=g.map.W; ++x) ................................................................................ 160 161 } 161 162 if(v[y][x]) continue; 162 163 if(y==s.y && x==s.x && i<4) { 163 164 char c = "UDRL"[i]; 164 165 if( death.count(c) == 0 ) 165 166 return [tuple(c,step)]; 166 167 } else if(forbidden_cell[y][x]){ 167 - } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||i>=4) { 168 + } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='!'||i>=4) { 168 169 if(danger(y,x)) 169 170 continue; 170 171 q2 ~= new Pos(y,x); 171 172 v[y][x]=true; 172 173 } 173 174 } 174 175 } ................................................................................ 200 201 } 201 202 if(v[y][x]) continue; 202 203 if(y==s.y && x==s.x && i<4) { 203 204 char c = "UDRL"[i]; 204 205 if( death.count(c) == 0 ) 205 206 return [tuple(c,step)]; 206 207 } else if(forbidden_cell[y][x]){ 207 - } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||i>=4) { 208 + } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='!'||i>=4) { 208 209 q2 ~= new Pos(y,x); 209 210 v[y][x]=true; 210 211 } 211 212 } 212 213 } 213 214 q = q2; 214 215 } ................................................................................ 243 244 } 244 245 if(v[y][x]) continue; 245 246 if(y==s.y && x==s.x && i<4) { 246 247 char c = "UDRL"[i]; 247 248 if( death.count(c) == 0 ) 248 249 return [tuple(c,step)]; 249 250 } else if(forbidden_cell[y][x]){ 250 - } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='*'||i>=4) { 251 + } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='*'||g.map[y,x]=='!'||i>=4) { 251 252 q2 ~= new Pos(y,x); 252 253 v[y][x]=true; 253 254 } 254 255 } 255 256 } 256 257 q = q2; 257 258 }