Diff
Not logged in

Differences From Artifact [7fa423ba9f8ebe92]:

To Artifact [3f9e2911ee63dc4e]:


1 import util; 1 import util; 2 import game; 2 import game; 3 import driver; 3 import driver; 4 import core.stdc.signal; 4 import core.stdc.signal; 5 5 6 class NilOutput : GameObserver 6 class NilOutput : GameObserver 7 { 7 { 8 this(const(Game) g) {} | 8 this(in Game g) {} 9 override void on_game_changed(char c, const(Game) g, bool finished) {} | 9 override void on_game_changed(char c, in Game g, bool finished) {} 10 } 10 } 11 11 12 class StdOutput : GameObserver 12 class StdOutput : GameObserver 13 { 13 { 14 this(const(Game) g) {} | 14 this(in Game g) {} 15 override void on_game_changed(char c, const(Game) g, bool finished) | 15 override void on_game_changed(char c, in Game g, bool finished) 16 { 16 { 17 stdout.write(c); 17 stdout.write(c); 18 stdout.flush(); 18 stdout.flush(); 19 } 19 } 20 } 20 } 21 21 22 class GuardedOutput : GameObserver 22 class GuardedOutput : GameObserver 23 { 23 { 24 this(const(Game) g) | 24 this(in Game g) 25 { 25 { 26 setup_sigint_handling(); 26 setup_sigint_handling(); 27 ideal_log ~= g.score_if_abort_now; 27 ideal_log ~= g.score_if_abort_now; 28 } 28 } 29 29 30 override void on_game_changed(char c, const(Game) g, bool finished) | 30 override void on_game_changed(char c, in Game g, bool finished) 31 { 31 { 32 log ~= c; 32 log ~= c; 33 score_log ~= g.score; 33 score_log ~= g.score; 34 ideal_log ~= g.score_if_abort_now; 34 ideal_log ~= g.score_if_abort_now; 35 if(finished) 35 if(finished) 36 flush(); 36 flush(); 37 } 37 }