Differences From Artifact [cabc7d361baa4f5a]:
- File
src/solver.d
- 2012-07-15 02:16:47 - part of checkin [34bbd14c1a] on branch trunk - Razor searching. (user: kinaba) [annotate]
To Artifact [df1ca9c8d7e8adb9]:
- File
src/solver.d
- 2012-07-15 02:24:14 - part of checkin [9f1a8c70cd] on branch trunk - Razor using solver. (user: kinaba) [annotate]
49 49
50 char act(const(Game) g, string death, int breath) 50 char act(const(Game) g, string death, int breath)
51 { 51 {
52 const Pos ro = g.map.robot; 52 const Pos ro = g.map.robot;
53 const Pos[] la = g.map.lambdas(); 53 const Pos[] la = g.map.lambdas();
54 const Pos[] ra = g.map.razors(); 54 const Pos[] ra = g.map.razors();
55 const Pos li = g.map.lift; 55 const Pos li = g.map.lift;
> 56 const Pos[] hi = g.map.objects('W');
56 57
57 Tuple!(char,int)[] cand; 58 Tuple!(char,int)[] cand;
58 char c = 'W'; 59 char c = 'W';
59 if( la.empty ) { 60 if( la.empty ) {
60 cand = search(g, ro, [li], death); 61 cand = search(g, ro, [li], death);
61 } else { 62 } else {
62 cand ~= search(g, ro, la~ra, death); 63 cand ~= search(g, ro, la~ra, death);
63 } 64 }
> 65
> 66 // 'higesori' mode
> 67 if( !hi.empty && g.map.razor>0 ) {
> 68 int his = 0;
> 69 for(int dy=-1; dy<=+1; ++dy)
> 70 for(int dx=-1; dx<=+1; ++dx)
> 71 if(g.map[ro.y+dy,ro.x+dx] == 'W')
> 72 his++;
> 73
> 74 if(his>=2 || his==hi.length)
> 75 cand = [tuple('S',int.max)];
> 76 if(cand.empty) {
> 77 const(Pos)[] tgt;
> 78 for(int y=1; y<=g.map.H; ++y)
> 79 for(int x=1; x<=g.map.W; ++x)
> 80 if(g.map[y,x]=='.'||g.map[y,x]==' ') {
> 81 his = 0;
> 82 for(int dy=-1; dy<=+1; ++dy)
> 83 for(int dx=-1; dx<=+1; ++dx)
> 84 if(g.map[y+dy,x+dx] == '
> 85 his++;
> 86 if(his>=2)
> 87 tgt ~= new Pos(y,x);
> 88 }
> 89 cand ~= search(g, ro, tgt, death, true);
> 90 }
> 91 }
64 92
65 // 'dig' mode 93 // 'dig' mode
66 if(cand.empty) { 94 if(cand.empty) {
67 const(Pos)[] tgt; 95 const(Pos)[] tgt;
68 for(int y=1; y<=g.map.H; ++y) 96 for(int y=1; y<=g.map.H; ++y)
69 for(int x=1; x<=g.map.W; ++x) 97 for(int x=1; x<=g.map.W; ++x)
70 if(g.map[y,x]=='.') 98 if(g.map[y,x]=='.')