Differences From Artifact [6a465bd844fac2d9]:
- File
src/solver.d
- 2012-07-14 14:33:25 - part of checkin [aea6cfc7e3] on branch trunk - further clean up. (user: kinaba) [annotate]
To Artifact [1708425009125a5d]:
- File
src/solver.d
- 2012-07-14 14:56:19 - part of checkin [c743b817b7] on branch trunk - death avoider for 'W'. (user: kinaba) [annotate]
5 5 {
6 6 this(const(Game) g) {}
7 7 char single_step() { return 'W'; }
8 8 }
9 9
10 10 class Solver_1
11 11 {
12 - int g_wc = 0;
12 + int wait_count = 0;
13 13
14 14 Game g;
15 15 this(const(Game) g)
16 16 {
17 17 this.g = g.clone();
18 18 forbidden_cell = new bool[][](g.map.H+2, g.map.W+2);
19 19 }
................................................................................
61 61 cand ~= tuple('W',int.max);
62 62 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
63 63 if(c1[1] != c2[1])
64 64 return c1[1] < c2[1];
65 65 return c1[0] < c2[0];
66 66 })(cand);
67 67 c = cand[0][0];
68 +
69 + if(death.count(c)) {
70 + foreach(char live; "UDLRWA")
71 + if(death.count(live)==0) {
72 + c=live;
73 + break;
74 + }
75 + }
68 76
69 77 if(c=='W') {
70 - g_wc++;
71 - if(g_wc > 10)
78 + wait_count++;
79 + if(wait_count > g.map.H)
72 80 c = 'A';
73 81 }
74 82 else
75 - g_wc = 0;
83 + wait_count = 0;
84 +
76 85 bool[char] choice;
77 86 foreach(t; cand)
78 87 choice[t[0]] = true;
79 88 log ~= tuple(ro.clone(), cast(int)choice.length);
80 89 if(log.length > 5)
81 90 log = log[$-5..$];
82 91 int cnt = 0;