Diff
Not logged in

Differences From Artifact [1e2f760afef7fe9f]:

To Artifact [b158ce3255b33a97]:


219 for(int x=1; x<=g.map.W; ++x) 219 for(int x=1; x<=g.map.W; ++x) 220 if(g.map[y,x]=='.') 220 if(g.map[y,x]=='.') 221 if(is_rocky(g.map[y+1,x])||is_rocky(g.ma 221 if(is_rocky(g.map[y+1,x])||is_rocky(g.ma 222 ||is_rocky(g.map[y,x+1])||is_rocky(g.ma 222 ||is_rocky(g.map[y,x+1])||is_rocky(g.ma 223 tgt ~= new Pos(y,x); 223 tgt ~= new Pos(y,x); 224 cand ~= search(g, ro, tgt, death, true); 224 cand ~= search(g, ro, tgt, death, true); 225 } 225 } > 226 > 227 // 'horo-push' mode > 228 if(cand.empty) { > 229 Pos[] horo = g.map.objects('@'); > 230 if(!horo.empty) { > 231 cand ~= search(g, ro, horo, death, true); > 232 } > 233 } 226 234 227 if(cand.empty) { 235 if(cand.empty) { 228 choke_count++; 236 choke_count++; 229 cand ~= tuple('W',int.max); 237 cand ~= tuple('W',int.max); 230 } 238 } 231 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 239 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 232 if(c1[1] != c2[1]) 240 if(c1[1] != c2[1]) ................................................................................................................................................................................ 294 Tuple!(char,int)[] tryA() { 302 Tuple!(char,int)[] tryA() { 295 const(Pos)[] q; 303 const(Pos)[] q; 296 foreach(p; gs) 304 foreach(p; gs) 297 if(!danger(p.y,p.x)) 305 if(!danger(p.y,p.x)) 298 q ~= p; 306 q ~= p; 299 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 307 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 300 foreach(p; q) v[p.y][p.x]=true; 308 foreach(p; q) v[p.y][p.x]=true; > 309 bool first_step = true; 301 for(int step=1; q.length; ++step) { 310 for(int step=1; q.length; ++step) { 302 Pos[] q2; 311 Pos[] q2; 303 foreach(p; q) { 312 foreach(p; q) { 304 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 313 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 305 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 314 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 306 string sss="URLD"; 315 string sss="URLD"; 307 for(int i=0; i<yyy.length; ++i) { | 316 for(int i=0; i<yyy.length; ++i) if(!firs 308 int y = yyy[i]; 317 int y = yyy[i]; 309 int x = xxx[i]; 318 int x = xxx[i]; 310 if('1'<=g.map[y,x]&&g.map[y,x]<= 319 if('1'<=g.map[y,x]&&g.map[y,x]<= 311 foreach(ppp; g.tr.source 320 foreach(ppp; g.tr.source 312 yyy ~= ppp.y; 321 yyy ~= ppp.y; 313 xxx ~= ppp.x; 322 xxx ~= ppp.x; 314 } 323 } ................................................................................................................................................................................ 324 if(danger(y,x)) 333 if(danger(y,x)) 325 continue; 334 continue; 326 q2 ~= new Pos(y,x); 335 q2 ~= new Pos(y,x); 327 v[y][x]=true; 336 v[y][x]=true; 328 } 337 } 329 } 338 } 330 } 339 } > 340 first_step = false; 331 q = q2; 341 q = q2; 332 } 342 } 333 return []; 343 return []; 334 } 344 } 335 345 336 // any empty space is my ground 346 // any empty space is my ground 337 Tuple!(char,int)[] tryB() { 347 Tuple!(char,int)[] tryB() { 338 const(Pos)[] q; 348 const(Pos)[] q; 339 foreach(p; gs) q ~= p; 349 foreach(p; gs) q ~= p; 340 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 350 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 341 foreach(p; q) v[p.y][p.x]=true; 351 foreach(p; q) v[p.y][p.x]=true; > 352 bool first_step = true; 342 for(int step=8; q.length; ++step) { 353 for(int step=8; q.length; ++step) { 343 Pos[] q2; 354 Pos[] q2; 344 foreach(p; q) { 355 foreach(p; q) { 345 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 356 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 346 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 357 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 347 string sss="URLD"; 358 string sss="URLD"; 348 for(int i=0; i<yyy.length; ++i) { | 359 for(int i=0; i<yyy.length; ++i) if(!firs 349 int y = yyy[i]; 360 int y = yyy[i]; 350 int x = xxx[i]; 361 int x = xxx[i]; 351 if('1'<=g.map[y,x]&&g.map[y,x]<= 362 if('1'<=g.map[y,x]&&g.map[y,x]<= 352 foreach(ppp; g.tr.source 363 foreach(ppp; g.tr.source 353 yyy ~= ppp.y; 364 yyy ~= ppp.y; 354 xxx ~= ppp.x; 365 xxx ~= ppp.x; 355 } 366 } ................................................................................................................................................................................ 363 } else if(forbidden_cell[y][x]){ 374 } else if(forbidden_cell[y][x]){ 364 } else if(g.map[y,x]==' '||g.map 375 } else if(g.map[y,x]==' '||g.map 365 q2 ~= new Pos(y,x); 376 q2 ~= new Pos(y,x); 366 v[y][x]=true; 377 v[y][x]=true; 367 } 378 } 368 } 379 } 369 } 380 } > 381 first_step = false; 370 q = q2; 382 q = q2; 371 } 383 } 372 return []; 384 return []; 373 } 385 } 374 386 375 // push rocks! 387 // push rocks! 376 Tuple!(char,int)[] tryC() { 388 Tuple!(char,int)[] tryC() { 377 const(Pos)[] q; 389 const(Pos)[] q; 378 foreach(p; gs) q ~= p; 390 foreach(p; gs) q ~= p; 379 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 391 bool[][] v = new bool[][](g.map.H+2, g.map.W+2); 380 foreach(p; q) v[p.y][p.x]=true; 392 foreach(p; q) v[p.y][p.x]=true; > 393 bool first_step = true; 381 for(int step=20; q.length; ++step) { 394 for(int step=20; q.length; ++step) { 382 Pos[] q2; 395 Pos[] q2; 383 foreach(p; q) { 396 foreach(p; q) { 384 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 397 int[] yyy=[p.y-1,p.y,p.y,p.y+1]; 385 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 398 int[] xxx=[p.x,p.x-1,p.x+1,p.x]; 386 string sss="URLD"; 399 string sss="URLD"; 387 for(int i=0; i<yyy.length; ++i) { | 400 for(int i=0; i<yyy.length; ++i) if(!firs 388 int y = yyy[i]; 401 int y = yyy[i]; 389 int x = xxx[i]; 402 int x = xxx[i]; 390 if(is_rocky(g.map[p])) { 403 if(is_rocky(g.map[p])) { 391 if(i>=4)continue; 404 if(i>=4)continue; 392 if(y!=p.y)continue; 405 if(y!=p.y)continue; 393 if(g.map[y,p.x+(p.x-x)]! 406 if(g.map[y,p.x+(p.x-x)]! 394 } 407 } ................................................................................................................................................................................ 407 } else if(forbidden_cell[y][x]){ 420 } else if(forbidden_cell[y][x]){ 408 } else if(g.map[y,x]==' '||g.map 421 } else if(g.map[y,x]==' '||g.map 409 q2 ~= new Pos(y,x); 422 q2 ~= new Pos(y,x); 410 v[y][x]=true; 423 v[y][x]=true; 411 } 424 } 412 } 425 } 413 } 426 } > 427 first_step = false; 414 q = q2; 428 q = q2; 415 } 429 } 416 return []; 430 return []; 417 } 431 } 418 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 432 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 419 } 433 } 420 } 434 }