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
- branch=trunk inherited from [16f0b5784f]
- sym-trunk inherited from [16f0b5784f]
Changes
Modified src/gui.d from [e185ff3281d95738] to [bcbc7e6a97423060].
17 private void delegate(char c) fn; 17 private void delegate(char c) fn; 18 void set_fn(F)(F f) { this.fn = f; } 18 void set_fn(F)(F f) { this.fn = f; } 19 19 20 void run(bool automate = false) 20 void run(bool automate = false) 21 { 21 { 22 if(automate) { 22 if(automate) { 23 Timer t = new Timer; 23 Timer t = new Timer; 24 t.interval = 100; | 24 t.interval = 50; 25 t.tick ~= (Timer sender, EventArgs ea){ 25 t.tick ~= (Timer sender, EventArgs ea){ 26 fn(solver.single_step()); 26 fn(solver.single_step()); 27 }; 27 }; 28 t.start(); 28 t.start(); 29 this.closing ~= (Form f,CancelEventArgs c){t.stop();}; 29 this.closing ~= (Form f,CancelEventArgs c){t.stop();}; 30 } 30 } 31 Application.run(this); 31 Application.run(this);
Modified src/solver.d from [dca756d0b000be21] to [7cfac19f78d8844c].
61 const(Pos)[] tgt; 61 const(Pos)[] tgt; 62 for(int y=1; y<=g.map.H; ++y) 62 for(int y=1; y<=g.map.H; ++y) 63 for(int x=1; x<=g.map.W; ++x) 63 for(int x=1; x<=g.map.W; ++x) 64 if(g.map[y,x]=='.') 64 if(g.map[y,x]=='.') 65 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='* 65 if(g.map[y+1,x]=='*'||g.map[y+1,x-1]=='* 66 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 66 ||g.map[y,x+1]=='*'||g.map[y,x-1]=='*') 67 tgt ~= new Pos(y,x); 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 if(cand.empty) 71 if(cand.empty) 72 cand ~= tuple('W',int.max); 72 cand ~= tuple('W',int.max); 73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 73 sort!((Tuple!(char,int) c1, Tuple!(char,int) c2){ 74 if(c1[1] != c2[1]) 74 if(c1[1] != c2[1]) 75 return c1[1] < c2[1]; 75 return c1[1] < c2[1]; ................................................................................................................................................................................ 106 if( cnt >= 3 && breath==1 ) { 106 if( cnt >= 3 && breath==1 ) { 107 forbidden_cell[ro.y][ro.x] = true; 107 forbidden_cell[ro.y][ro.x] = true; 108 } 108 } 109 109 110 return c; 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 114 { 114 { 115 bool danger(int y, int x) 115 bool danger(int y, int x) 116 { 116 { > 117 if(g.map[y,x] == ' ' || g.map[y,x] == 'R') > 118 return false; 117 if(g.map[y+1,x] == '*') 119 if(g.map[y+1,x] == '*') 118 return true; 120 return true; 119 if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x 121 if(g.map[y+1,x-1]=='*' && (g.map[y,x-1]=='\\'||g.map[y,x 120 return true; 122 return true; 121 if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[ 123 if(g.map[y+1,x+1]=='*' && (g.map[y,x+1]=='*') && (g.map[ 122 return true; 124 return true; 123 if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1 125 if(g.map[y,x-1]=='*' && (g.map[y-1,x-1]=='\\'||g.map[y-1 ................................................................................................................................................................................ 222 } 224 } 223 } 225 } 224 } 226 } 225 q = q2; 227 q = q2; 226 } 228 } 227 return []; 229 return []; 228 } 230 } 229 return tryA() ~ tryB() ~ tryC(); | 231 return (danger_ok ? [] : tryA()) ~ tryB() ~ tryC(); 230 } 232 } 231 } 233 }