Index: src/output.d ================================================================== --- src/output.d +++ src/output.d @@ -23,25 +23,30 @@ { this(in Game g) { setup_sigint_handling(); ideal_log ~= g.score_if_abort_now; + flushed = false; } override void on_game_changed(char c, in Game g, bool finished) { + if(flushed) + return; + log ~= c; score_log ~= g.score; ideal_log ~= g.score_if_abort_now; - if(finished) + if(finished || log.length+1==g.map.W*g.map.H) flush(); } private: string log; long[] score_log; long[] ideal_log; + bool flushed; void flush() { Tuple!(long, int, int) cand; cand[0] = long.min; @@ -59,10 +64,11 @@ } else { string str = log[0..cand[1]]; std.c.stdio.printf("%.*sA\n", str.length, str.ptr); } std.c.stdio.fflush(std.c.stdio.stdout); + flushed = true; } private: static __gshared GuardedOutput g_output;