Check-in [6e4c06b018]
Not logged in
Overview
SHA1 Hash:6e4c06b01887a43d7eea6e7b518fa246cd1330e3
Date: 2012-07-15 03:00:27
User: kinaba
Comment:Solver supports trampoline.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/solver.d from [69c19d5fe197eaad] to [4aac390deb513002].

136 if(!danger(p.y,p.x)) 136 if(!danger(p.y,p.x)) 137 q ~= p; 137 q ~= p; 138 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 138 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 139 foreach(p; q) v[p.y][p.x]=true; 139 foreach(p; q) v[p.y][p.x]=true; 140 for(int step=1; q.length; ++step) { 140 for(int step=1; q.length; ++step) { 141 Pos[] q2; 141 Pos[] q2; 142 foreach(p; q) { 142 foreach(p; q) { 143 int[] dy=[-1,+1,0,0]; | 143 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; 144 int[] dx=[0,0,-1,+1]; | 144 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; 145 for(int i=0; i<4; ++i) { | 145 for(int i=0; i<yyy.length; ++i) { 146 int y = p.y+dy[i]; | 146 int y = yyy[i]; 147 int x = p.x+dx[i]; | 147 int x = xxx[i]; > 148 if('1'<=g.map[y,x]&&g.map[y,x]<= > 149 foreach(ppp; g.map.tr_so > 150 yyy ~= ppp.y; > 151 xxx ~= ppp.x; > 152 } > 153 continue; > 154 } 148 if(v[y][x]) continue; 155 if(v[y][x]) continue; 149 if(y==s.y && x==s.x) { | 156 if(y==s.y && x==s.x && i<4) { 150 char c = "UDRL"[i]; 157 char c = "UDRL"[i]; 151 if( death.count(c) == 0 158 if( death.count(c) == 0 152 return [tuple(c, 159 return [tuple(c, 153 } else if(forbidden_cell[y][x]){ 160 } else if(forbidden_cell[y][x]){ 154 } else if(g.map[y,x]==' '||g.map | 161 } else if(g.map[y,x]==' '||g.map 155 if(danger(y,x)) 162 if(danger(y,x)) 156 continue; 163 continue; 157 q2 ~= new Pos(y,x); 164 q2 ~= new Pos(y,x); 158 v[y][x]=true; 165 v[y][x]=true; 159 } 166 } 160 } 167 } 161 } 168 } ................................................................................................................................................................................ 169 const(Pos)[] q; 176 const(Pos)[] q; 170 foreach(p; gs) q ~= p; 177 foreach(p; gs) q ~= p; 171 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 178 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 172 foreach(p; q) v[p.y][p.x]=true; 179 foreach(p; q) v[p.y][p.x]=true; 173 for(int step=10; q.length; ++step) { 180 for(int step=10; q.length; ++step) { 174 Pos[] q2; 181 Pos[] q2; 175 foreach(p; q) { 182 foreach(p; q) { 176 int[] dy=[-1,+1,0,0]; | 183 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; 177 int[] dx=[0,0,-1,+1]; | 184 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; 178 for(int i=0; i<4; ++i) { | 185 for(int i=0; i<yyy.length; ++i) { 179 int y = p.y+dy[i]; | 186 int y = yyy[i]; 180 int x = p.x+dx[i]; | 187 int x = xxx[i]; > 188 if('1'<=g.map[y,x]&&g.map[y,x]<= > 189 foreach(ppp; g.map.tr_so > 190 yyy ~= ppp.y; > 191 xxx ~= ppp.x; > 192 } > 193 continue; > 194 } 181 if(v[y][x]) continue; 195 if(v[y][x]) continue; 182 if(y==s.y && x==s.x) { | 196 if(y==s.y && x==s.x && i<4) { 183 char c = "UDRL"[i]; 197 char c = "UDRL"[i]; 184 if( death.count(c) == 0 198 if( death.count(c) == 0 185 return [tuple(c, 199 return [tuple(c, 186 } else if(forbidden_cell[y][x]){ 200 } else if(forbidden_cell[y][x]){ 187 } else if(g.map[y,x]==' '||g.map | 201 } else if(g.map[y,x]==' '||g.map 188 q2 ~= new Pos(y,x); 202 q2 ~= new Pos(y,x); 189 v[y][x]=true; 203 v[y][x]=true; 190 } 204 } 191 } 205 } 192 } 206 } 193 q = q2; 207 q = q2; 194 } 208 } ................................................................................................................................................................................ 200 const(Pos)[] q; 214 const(Pos)[] q; 201 foreach(p; gs) q ~= p; 215 foreach(p; gs) q ~= p; 202 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 216 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 203 foreach(p; q) v[p.y][p.x]=true; 217 foreach(p; q) v[p.y][p.x]=true; 204 for(int step=20; q.length; ++step) { 218 for(int step=20; q.length; ++step) { 205 Pos[] q2; 219 Pos[] q2; 206 foreach(p; q) { 220 foreach(p; q) { 207 int[] dy=[-1,+1,0,0]; | 221 int[] yyy=[p.y-1,p.y+1,p.y,p.y]; 208 int[] dx=[0,0,-1,+1]; | 222 int[] xxx=[p.x,p.x,p.x-1,p.x+1]; 209 for(int i=0; i<4; ++i) { | 223 for(int i=0; i<yyy.length; ++i) { 210 int y = p.y+dy[i]; | 224 int y = yyy[i]; 211 int x = p.x+dx[i]; | 225 int x = xxx[i]; > 226 if('1'<=g.map[y,x]&&g.map[y,x]<= > 227 foreach(ppp; g.map.tr_so > 228 yyy ~= ppp.y; > 229 xxx ~= ppp.x; > 230 } > 231 continue; > 232 } 212 if(v[y][x]) continue; 233 if(v[y][x]) continue; 213 if(y==s.y && x==s.x) { | 234 if(y==s.y && x==s.x && i<4) { 214 char c = "UDRL"[i]; 235 char c = "UDRL"[i]; 215 if( death.count(c) == 0 236 if( death.count(c) == 0 216 return [tuple(c, 237 return [tuple(c, 217 } else if(forbidden_cell[y][x]){ 238 } else if(forbidden_cell[y][x]){ 218 } else if(g.map[y,x]==' '||g.map | 239 } else if(g.map[y,x]==' '||g.map 219 q2 ~= new Pos(y,x); 240 q2 ~= new Pos(y,x); 220 v[y][x]=true; 241 v[y][x]=true; 221 } else if(dy[i]==0 && g.map[p]== | 242 } else if(i<4 && (y-p.y)==0 && g 222 q2 ~= new Pos(y,x); 243 q2 ~= new Pos(y,x); 223 v[y][x]=true; 244 v[y][x]=true; 224 } 245 } 225 } 246 } 226 } 247 } 227 q = q2; 248 q = q2; 228 } 249 }