Differences From Artifact [4aac390deb513002]:
- File
src/solver.d
- 2012-07-14 18:00:27 - part of checkin [6e4c06b018] on branch trunk - Solver supports trampoline. (user: kinaba) [annotate]
To Artifact [01f7e924127970bf]:
- File
src/solver.d
- 2012-07-14 18:26:12 - part of checkin [2f2eff2f03] on branch trunk - fall rock mode. (user: kinaba) [annotate]
33 33 foreach(char c; "UDLRW") {
34 34 Game gg = g.clone();
35 35 gg.command(c);
36 36 if( !gg.cleared && gg.dead )
37 37 death ~= c;
38 38 else if( gg.map.robot != g.map.robot )
39 39 choice++;
40 + else if( c != 'W' ) // meaningless move
41 + death ~= c;
40 42 }
41 43 return tuple(death, choice);
42 44 }
43 45
44 46 Tuple!(Pos, int)[] log;
45 47 bool[][] forbidden_cell;
46 48
................................................................................
53 55 Tuple!(char,int)[] cand;
54 56 char c = 'W';
55 57 if( la.empty ) {
56 58 cand = search(g, ro, [li], death);
57 59 } else {
58 60 cand ~= search(g, ro, la, death);
59 61 }
62 +
63 + // 'dig' mode
60 64 if(cand.empty) {
61 65 const(Pos)[] tgt;
62 66 for(int y=1; y<=g.map.H; ++y)
63 67 for(int x=1; x<=g.map.W; ++x)
64 68 if(g.map[y,x]=='.')
65 69 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*'||g.map[y+1,x+1]=='*'
66 70 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*')
................................................................................
73 77 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
74 78 if(c1[1] != c2[1])
75 79 return c1[1] < c2[1];
76 80 return c1[0] < c2[0];
77 81 })(cand);
78 82 c = cand[0][0];
79 83
80 - if(death.count(c)) {
81 - foreach(char live; "UDLRWA")
84 + if(death.count(c) || wait_count>=2) {
85 + foreach(char live; "UDLRW")
82 86 if(death.count(live)==0) {
83 87 c=live;
84 88 break;
85 89 }
86 90 }
87 91
88 92 if(c=='W') {