Check-in [9f1a8c70cd]
Not logged in
Overview
SHA1 Hash:9f1a8c70cd6a351d14f7692c5e75131e0b2957f7
Date: 2012-07-15 11:24:14
User: kinaba
Comment:Razor using solver.
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 [cabc7d361baa4f5a] to [df1ca9c8d7e8adb9].

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]=='.')