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
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified src/game.d from [09842c914b3d99f0] to [5d6b45c159e125db].
216 } 216 } 217 217 218 void opIndexAssign(char c, in Pos p) 218 void opIndexAssign(char c, in Pos p) 219 { 219 { 220 this[p.y, p.x] = c; 220 this[p.y, p.x] = c; 221 } 221 } 222 222 223 Pos[] lambdas() const { | 223 Pos[] objects(char c) const { 224 Pos[] ans; 224 Pos[] ans; 225 for(int y=1; y<=H; ++y) 225 for(int y=1; y<=H; ++y) 226 for(int x=1; x<=W; ++x) 226 for(int x=1; x<=W; ++x) 227 if(this[y,x] == '\\') | 227 if(this[y,x] == c) 228 ans ~= new Pos(y,x); 228 ans ~= new Pos(y,x); 229 return ans; 229 return ans; 230 } 230 } 231 231 > 232 Pos[] razors() const { return objects('!'); } > 233 Pos[] lambdas() const { return objects('\\'); } > 234 232 bool cleared() const 235 bool cleared() const 233 { 236 { 234 for(int y=1; y<=H; ++y) 237 for(int y=1; y<=H; ++y) 235 for(int x=1; x<=W; ++x) 238 for(int x=1; x<=W; ++x) 236 if(this[y,x] == 'L' || this[y,x] == 'O') 239 if(this[y,x] == 'L' || this[y,x] == 'O') 237 return false; 240 return false; 238 return true; 241 return true;
Modified src/solver.d from [673d840a0e1a2769] to [cabc7d361baa4f5a].
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 }