Diff
Not logged in

Differences From Artifact [62e6040714438eff]:

To Artifact [ef5cfcc2ac51c863]:


20 20 } 21 21 22 22 class GuardedOutput : GameObserver 23 23 { 24 24 this(in Game g) 25 25 { 26 26 setup_sigint_handling(); 27 - ideal_log ~= g.score_if_abort_now; 27 + score_log ~= g.score; 28 28 flushed = false; 29 29 } 30 30 31 31 override void on_game_changed(char c, in Game g, bool finished) 32 32 { 33 33 if(flushed) 34 34 return; 35 35 36 36 log ~= c; 37 37 score_log ~= g.score; 38 - ideal_log ~= g.score_if_abort_now; 39 38 if(finished || log.length+1==g.map.W*g.map.H) 40 39 flush(); 41 40 } 42 41 43 42 private: 44 43 string log; 45 44 long[] score_log; 46 - long[] ideal_log; 47 45 bool flushed; 48 46 49 47 void flush() 50 48 { 51 - Tuple!(long, int, int) cand; 49 + Tuple!(long, int) cand; 52 50 cand[0] = long.min; 53 51 54 52 for(int i=0; i<score_log.length; ++i) 55 53 if(cand[0] < score_log[i]) 56 - cand = tuple(score_log[i],i,0); 57 - for(int i=0; i<ideal_log.length; ++i) 58 - if(cand[0] < ideal_log[i]) 59 - cand = tuple(ideal_log[i],i,1); 54 + cand = tuple(score_log[i],i); 60 55 61 - if(cand[2]==0) { 62 - string str = log[0..cand[1]+1]; 63 - std.c.stdio.printf("%.*s\n", str.length, str.ptr); 64 - } else { 65 - string str = log[0..cand[1]]; 66 - std.c.stdio.printf("%.*sA\n", str.length, str.ptr); 67 - } 56 + std.c.stdio.printf("%.*sA\n", cand[1], log.ptr); 68 57 std.c.stdio.fflush(std.c.stdio.stdout); 69 58 flushed = true; 70 59 } 71 60 72 61 private: 73 62 static __gshared GuardedOutput g_output; 74 63