Index: score_memo.txt ================================================================== --- score_memo.txt +++ score_memo.txt @@ -1,22 +1,22 @@ contest1 212! contest2 280? contest3 275! contest4 561? contest5 1281? -contest6 737 +contest6 737 // deadend trap contest7 867? -contest8 1245 +contest8 1245 // tricky contest9 3042? -contest10 2076 -flood1 569 +contest10 2076 // * on lambda, must move * first +flood1 569 // too slow, because of 1-left danger lambda flood2 280? -flood3 802 -flood4 970 +flood3 802 // too slow, drown +flood4 970 // incorrect order of digging flood5 561? -trampoline1 291 +trampoline1 291 // * on trampoline. must move * first trampoline2 1728? -trampoline3 698 +trampoline3 698 // * on trampoline target. must move * first. beard1 856? -beard2 2792 -beard3 811 -beard4 677 +beard2 2792 // hutsu-ni muzui +beard3 811 // tricky. must hurry to cut hige. +beard4 677 // deadend trap Index: src/cui_auto_main.d ================================================================== --- src/cui_auto_main.d +++ src/cui_auto_main.d @@ -16,10 +16,12 @@ } void main(string[] args) { Driver d = new Driver(stdin); - d.addObserver!(GuardedOutput)(); - auto c = d.addObserver!(CUI!MainSolver)(); +// d.addObserver!(GuardedOutput)(); + d.addObserver!(StdOutput)(); +// auto c = d.addObserver!(CUI!MainSolver)(); + auto c = d.addObserver!(CUI!Solver_0)(); while(!c.fin) d.command(c.solver.single_step()); } Index: src/game.d ================================================================== --- src/game.d +++ src/game.d @@ -235,11 +235,11 @@ for(int x=1; x<=W; ++x) if(this[y,x] == 'L' || this[y,x] == 'O') return false; return true; } - + Tuple!(int,bool) command(char c, int turn) { assert( this[robot] == 'R' ); if(c=='R') return move( 0, +1, turn); if(c=='L') return move( 0, -1, turn); @@ -348,11 +348,11 @@ return dead; } } //////////////////////////////////////////////////////////////////////////////// - +/* class Game { mixin DeriveShow; static Game load(File input) @@ -442,5 +442,378 @@ int water_until_rise() { return water.until_rise(turn); } int hige_until_rise() { return map.hige.until_rise(turn); } int hp() { return map.waterproof - under_water; } } } +*/ + +//////////////////////////////////////////////////////////////////////////////// + +class Game +{ +public: + this(File input) + { + // Read map data + string[] map_data_lines; + for(string line; !(line=input.readln().chomp()).empty; ) + map_data_lines ~= line; + + // H*W + H_ = map_data_lines.length; + W_ = 0; + foreach(mdl; map_data_lines) + W_ = max(W_, mdl.length); + + // Copy to modifiable buffer and adjust coordinates. + raw_data_ = new char[][H_+1]; + foreach(i,mdl; map_data_lines) { + char[] buf = new char[mdl.length+1]; + buf[0] = '#'; + buf[1..$] = mdl[]; + raw_data_[H_-i] = buf; + } + + // Detect objects + for(int y=1; y<=H_; ++y) + for(int x=1; x