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 this(const(Game) g) {} 6 this(const(Game) g) {}
7 char single_step() { return 'W'; } 7 char single_step() { return 'W'; }
8 } 8 }
9 9
10 class Solver_1 10 class Solver_1
11 { 11 {
12 int g_wc = 0; | 12 int wait_count = 0;
13 13
14 Game g; 14 Game g;
15 this(const(Game) g) 15 this(const(Game) g)
16 { 16 {
17 this.g = g.clone(); 17 this.g = g.clone();
18 forbidden_cell = new bool[][](g.map.H+2, g.map.W+2); 18 forbidden_cell = new bool[][](g.map.H+2, g.map.W+2);
19 } 19 }
................................................................................................................................................................................
61 cand ~= tuple('W',int.max); 61 cand ~= tuple('W',int.max);
62 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 62 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){
63 if(c1[1] != c2[1]) 63 if(c1[1] != c2[1])
64 return c1[1] < c2[1]; 64 return c1[1] < c2[1];
65 return c1[0] < c2[0]; 65 return c1[0] < c2[0];
66 })(cand); 66 })(cand);
67 c = cand[0][0]; 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 if(c=='W') { 77 if(c=='W') {
70 g_wc++; | 78 wait_count++;
71 if(g_wc > 10) | 79 if(wait_count > g.map.H)
72 c = 'A'; 80 c = 'A';
73 } 81 }
74 else 82 else
75 g_wc = 0; | 83 wait_count = 0;
> 84
76 bool[char] choice; 85 bool[char] choice;
77 foreach(t; cand) 86 foreach(t; cand)
78 choice[t[0]] = true; 87 choice[t[0]] = true;
79 log ~= tuple(ro.clone(), cast(int)choice.length); 88 log ~= tuple(ro.clone(), cast(int)choice.length);
80 if(log.length > 5) 89 if(log.length > 5)
81 log = log[$-5..$]; 90 log = log[$-5..$];
82 int cnt = 0; 91 int cnt = 0;