Overview
SHA1 Hash: | c88611bab83354c60a9dfc185a9659f6297f8cfe |
---|---|
Date: | 2012-07-15 21:40:58 |
User: | kinaba |
Comment: | horock solver |
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/solver.d from [393baf841678f948] to [8629f9c48aba56fd].
1 1 import util; 2 2 import game; 3 3 4 +bool rocky(char c){ return c=='*'||c=='@'; } 5 + 4 6 class Solver_0 5 7 { 6 8 this(in Game g) {} 7 9 char single_step() { return 'W'; } 8 10 void force(char c) {} 9 11 } 10 12 ................................................................................ 104 106 105 107 // 'dig' mode 106 108 if(cand.empty) { 107 109 const(Pos)[] tgt; 108 110 for(int y=1; y<=g.map.H; ++y) 109 111 for(int x=1; x<=g.map.W; ++x) 110 112 if(g.map[y,x]=='.') 111 - if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*'||g.map[y+1,x+1]=='*' 112 - ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 113 + if(rocky(g.map[y+1,x])||rocky(g.map[y+1,x-1])||rocky(g.map[y+1,x+1]) 114 + ||rocky(g.map[y,x+1])||rocky(g.map[y,x-1])) 113 115 tgt ~= new Pos(y,x); 114 116 cand ~= search(g, ro, tgt, death, true); 115 117 } 116 118 117 119 if(cand.empty) { 118 120 choke_count++; 119 121 cand ~= tuple('W',int.max); ................................................................................ 159 161 160 162 Tuple!(char,int)[] search(in Game g, in Pos s, in Pos[] gs, string death, bool danger_ok=false) 161 163 { 162 164 bool danger(int y, int x) 163 165 { 164 166 if(g.map[y,x] == ' ' || g.map[y,x] == 'R') 165 167 return false; 166 - if(g.map[y+1,x] == '*') 168 + if(rocky(g.map[y+1,x])) 169 + return true; 170 + if(rocky(g.map[y+1,x-1]) && (g.map[y,x-1]=='\\'||rocky(g.map[y,x-1])) && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 167 171 return true; 168 - if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x-1]=='*') && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 172 + if(rocky(g.map[y+1,x+1]) && rocky(g.map[y,x+1]) && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 169 173 return true; 170 - if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 174 + if(rocky(g.map[y,x-1]) && (g.map[y-1,x-1]=='\\'||rocky(g.map[y-1,x-1])) && (g.map[y-1,x]==' '||g.map[y-1,x]=='R')) 171 175 return true; 172 - if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1,x-1]=='*') && (g.map[y-1,x]==' '||g.map[y-1,x]=='R')) 173 - return true; 174 - if(g.map[y,x+1]=='*' && (g.map[y-1,x+1]=='*') && (g.map[y-1,x]==' '||g.map[y-1,x]=='R')) 176 + if(rocky(g.map[y,x+1]) && rocky(g.map[y-1,x+1]) && (g.map[y-1,x]==' '||g.map[y-1,x]=='R')) 175 177 return true; 176 178 return false; 177 179 } 178 180 179 181 // avoid directly below '*' 180 182 Tuple!(char,int)[] tryA() { 181 183 const(Pos)[] q; ................................................................................ 266 268 Pos[] q2; 267 269 foreach(p; q) { 268 270 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; 269 271 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; 270 272 for(int i=0; i<yyy.length; ++i) { 271 273 int y = yyy[i]; 272 274 int x = xxx[i]; 273 - if(g.map[p] == '*') { 275 + if(rocky(g.map[p])) { 274 276 if(i>=4)continue; 275 277 if(y!=p.y)continue; 276 278 if(g.map[y,p.x+(p.x-x)]!=' '&&g.map[y,p.x+(p.x-x)]!='R')continue; 277 279 } 278 280 if('1'<=g.map[y,x]&&g.map[y,x]<='9') { 279 281 foreach(ppp; g.map.tr_source[g.map[y,x]]) { 280 282 yyy ~= ppp.y; ................................................................................ 284 286 } 285 287 if(v[y][x]) continue; 286 288 if(y==s.y && x==s.x && i<4) { 287 289 char c = "UDRL"[i]; 288 290 if( death.count(c) == 0 ) 289 291 return [tuple(c,step)]; 290 292 } else if(forbidden_cell[y][x]){ 291 - } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||g.map[y,x]=='*'||g.map[y,x]=='!'||i>=4) { 293 + } else if(g.map[y,x]==' '||g.map[y,x]=='\\'||g.map[y,x]=='.'||rocky(g.map[y,x])||g.map[y,x]=='!'||i>=4) { 292 294 q2 ~= new Pos(y,x); 293 295 v[y][x]=true; 294 296 } 295 297 } 296 298 } 297 299 q = q2; 298 300 }