Check-in [0c10424b3c]
Not logged in
Overview
SHA1 Hash:0c10424b3c56d4c66e59e3e25c7caee5c19225ba
Date: 2012-07-15 01:04:29
User: kinaba
Comment:Minor fix for danger avoidance.
Timelines: family | ancestors | descendants | both | trunk
Diffs: redesign
Downloads: Tarball | ZIP archive
Other Links: files | file ages | manifest
Tags And Properties
Changes

Modified src/gui.d from [e185ff3281d95738] to [bcbc7e6a97423060].

17 17 private void delegate(char c) fn; 18 18 void set_fn(F)(F f) { this.fn = f; } 19 19 20 20 void run(bool automate = false) 21 21 { 22 22 if(automate) { 23 23 Timer t = new Timer; 24 - t.interval = 100; 24 + t.interval = 50; 25 25 t.tick ~= (Timer sender, EventArgs ea){ 26 26 fn(solver.single_step()); 27 27 }; 28 28 t.start(); 29 29 this.closing ~= (Form f,CancelEventArgs c){t.stop();}; 30 30 } 31 31 Application.run(this);

Modified src/solver.d from [dca756d0b000be21] to [7cfac19f78d8844c].

61 61 const(Pos)[] tgt; 62 62 for(int y=1; y<=g.map.H; ++y) 63 63 for(int x=1; x<=g.map.W; ++x) 64 64 if(g.map[y,x]=='.') 65 65 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='*'||g.map[y+1,x+1]=='*' 66 66 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 67 67 tgt ~= new Pos(y,x); 68 - cand ~= search(g, ro, tgt, death); 68 + cand ~= search(g, ro, tgt, death, true); 69 69 } 70 70 71 71 if(cand.empty) 72 72 cand ~= tuple('W',int.max); 73 73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 74 74 if(c1[1] != c2[1]) 75 75 return c1[1] < c2[1]; ................................................................................ 106 106 if( cnt >= 3 && breath==1 ) { 107 107 forbidden_cell[ro.y][ro.x] = true; 108 108 } 109 109 110 110 return c; 111 111 } 112 112 113 - Tuple!(char,int)[] search(in Game g, in Pos s, in Pos[] gs, string death) 113 + Tuple!(char,int)[] search(in Game g, in Pos s, in Pos[] gs, string death, bool danger_ok=false) 114 114 { 115 115 bool danger(int y, int x) 116 116 { 117 + if(g.map[y,x] == ' ' || g.map[y,x] == 'R') 118 + return false; 117 119 if(g.map[y+1,x] == '*') 118 120 return true; 119 121 if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x-1]=='*') && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 120 122 return true; 121 123 if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[y+1,x]==' '||g.map[y+1,x]=='R')) 122 124 return true; 123 125 if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1,x-1]=='*') && (g.map[y-1,x]==' '||g.map[y-1,x]=='R')) ................................................................................ 222 224 } 223 225 } 224 226 } 225 227 q = q2; 226 228 } 227 229 return []; 228 230 } 229 - return tryA() ~ tryB() ~ tryC(); 231 + return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 230 232 } 231 233 }