Diff
Not logged in

Differences From Artifact [2ca374354297c908]:

To Artifact [7fa423ba9f8ebe92]:


1 import util; 1 import util; 2 import game; 2 import game; 3 import driver; 3 import driver; 4 import std.c.stdlib; < 5 import core.stdc.signal; 4 import core.stdc.signal; 6 5 7 class NilOutput : GameObserver 6 class NilOutput : GameObserver 8 { 7 { 9 this(const(Game) g) {} 8 this(const(Game) g) {} 10 override bool on_game_changed(char c, const(Game) g, bool finished) {ret | 9 override void on_game_changed(char c, const(Game) g, bool finished) {} 11 } 10 } 12 11 13 class StdOutput : GameObserver 12 class StdOutput : GameObserver 14 { 13 { 15 this(const(Game) g) {} 14 this(const(Game) g) {} 16 override bool on_game_changed(char c, const(Game) g, bool finished) | 15 override void on_game_changed(char c, const(Game) g, bool finished) 17 { 16 { 18 stdout.write(c); 17 stdout.write(c); 19 stdout.flush(); 18 stdout.flush(); 20 return false; < 21 } 19 } 22 } 20 } 23 21 24 class GuardedOutput : GameObserver 22 class GuardedOutput : GameObserver 25 { 23 { 26 this(const(Game) g) 24 this(const(Game) g) 27 { 25 { 28 setup_sigint_handling(); 26 setup_sigint_handling(); 29 ideal_log ~= g.score_if_abort_now; 27 ideal_log ~= g.score_if_abort_now; 30 } 28 } 31 29 32 override bool on_game_changed(char c, const(Game) g, bool finished) | 30 override void on_game_changed(char c, const(Game) g, bool finished) 33 { 31 { 34 log ~= c; 32 log ~= c; 35 score_log ~= g.score; 33 score_log ~= g.score; 36 ideal_log ~= g.score_if_abort_now; 34 ideal_log ~= g.score_if_abort_now; 37 if(finished) 35 if(finished) 38 flush(); 36 flush(); 39 return false; < 40 } 37 } 41 38 42 private: 39 private: 43 string log; 40 string log; 44 long[] score_log; 41 long[] score_log; 45 long[] ideal_log; 42 long[] ideal_log; 46 43