Index: src/solver.d ================================================================== --- src/solver.d +++ src/solver.d @@ -164,10 +164,14 @@ Tuple!(Pos, int)[] log; bool[][] forbidden_cell; char act(const(Game) g, string death, int breath) { + foreach(char c; "UDLR") + if( death.count(c)==0 && is_one_way_load(g,c) ) + return c; + const Pos ro = g.map.robot; const Pos li = g.map.lift; Pos[] la = g.map.lambdas(); sort!((Pos a,Pos b){ int ad=abs(a.y-li.y)+abs(a.x-li.x); @@ -450,10 +454,54 @@ } return []; } return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); } + + bool is_one_way_load(in Game g, char c) + { + Pos p = g.map.robot.clone(); + Pos q; + if(c=='U') q=new Pos(p.y+1,p.x); + if(c=='D') q=new Pos(p.y-1,p.x); + if(c=='L') q=new Pos(p.y,p.x-1); + if(c=='R') q=new Pos(p.y,p.x+1); + char d = g.map[q]; + if(!(d==' '||d=='.'||d=='!')) + return false; + + bool found_lambda = false; + int[4] dy=[-1,+1,0,0]; + int[4] dx=[0,0,+1,-1]; + for(;;) + { + Pos r = null; + for(int i=0; i<4; ++i) { + int y=q.y+dy[i]; + int x=q.x+dx[i]; + if(x==p.x && y==p.y) + continue; + char e = g.map[y,x]; + if(e=='#') + continue; + if(e==' '||e=='.'||e=='!'||e=='R'||e=='\\') { + if(r !is null) + return false; + r = new Pos(y,x); + if(e=='\\') + found_lambda = true; + continue; + } + return false; + } + if(r is null) + break; + p=q; + q=r; + } + return found_lambda; + } } /// /// Solver "Fire": in raiding and plundering other solvers, be like fire. /// @@ -761,6 +809,6 @@ } alias 侵掠如火!(疾如風!(false)) FastSolver; alias Switcher MainSolver; -//alias 侵掠如火!(徐如林) MainSolver; +//alias 徐如林 MainSolver;