Check-in [ea96f24715]
Not logged in
Overview
SHA1 Hash:ea96f24715afb12ba7911b892f07ad1ab1b46a59
Date: 2012-07-15 03:33:18
User: kinaba
Comment:Introduced choke_count to cumlatively count the robot chose to "wait"
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/solver.d from [01f7e924127970bf] to [d8cdcee0dd6dc539].

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 12 int wait_count = 0; 13 + int choke_count = 0; 13 14 14 15 Game g; 15 16 this(const(Game) g) 16 17 { 17 18 this.g = g.clone(); 18 19 forbidden_cell = new bool[][](g.map.H+2, g.map.W+2); 19 20 } ................................................................................ 68 69 if(g.map[y,x]=='.') 69 70 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*'||g.map[y+1,x+1]=='*' 70 71 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 71 72 tgt ~= new Pos(y,x); 72 73 cand ~= search(g, ro, tgt, death, true); 73 74 } 74 75 75 - if(cand.empty) 76 + if(cand.empty) { 77 + choke_count++; 76 78 cand ~= tuple('W',int.max); 79 + } 77 80 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 78 81 if(c1[1] != c2[1]) 79 82 return c1[1] < c2[1]; 80 83 return c1[0] < c2[0]; 81 84 })(cand); 82 85 c = cand[0][0]; 83 86 ................................................................................ 85 88 foreach(char live; "UDLRW") 86 89 if(death.count(live)==0) { 87 90 c=live; 88 91 break; 89 92 } 90 93 } 91 94 92 - if(c=='W') { 95 + if(c == 'W') 93 96 wait_count++; 94 - if(wait_count > g.map.H) 95 - c = 'A'; 96 - } 97 97 else 98 98 wait_count = 0; 99 + if(choke_count >= g.map.H) 100 + c = 'A'; 99 101 100 102 bool[char] choice; 101 103 foreach(t; cand) 102 104 choice[t[0]] = true; 103 105 log ~= tuple(ro.clone(), cast(int)choice.length); 104 106 if(log.length > 5) 105 107 log = log[$-5..$];