5 #include "ai_controller.h"
6 #include "human_controller.h"
11 * Class to manage the game
12 * Bit messy since I keep adding on parameters :P
17 Game(const char * redPath, const char * bluePath, const bool enableGraphics, double newStallTime = 1.0, const bool allowIllegal=false, FILE * newLog = NULL, const Piece::Colour & newRevealed = Piece::BOTH, int maxTurns = 5000, const bool printBoard = false, double newTimeoutTime = 2.0);
18 Game(const char * fromFile, const bool enableGraphics, double newStallTime = 1.0, const bool allowIllegal=false, FILE * newLog = NULL, const Piece::Colour & newRevealed = Piece::BOTH, int maxTurns = 5000, const bool printBoard = false, double newTimeoutTime = 2.0);
23 void Wait(double wait);
25 Piece::Colour Setup(const char * redName, const char * blueName);
26 MovementResult Play();
27 void PrintEndMessage(const MovementResult & result);
30 static void HandleBrokenPipe(int signal);
31 void ReadUserCommand();
33 const Piece::Colour Turn() const {return turn;}
34 void ForceTurn(const Piece::Colour & newTurn) {turn = newTurn;}
35 int TurnCount() const {return turnCount;}
37 static Game * theGame;
38 static int Tokenise(std::vector<std::string> & buffer, std::string & str, char split = ' '); //Helper - Split a string into tokens
40 int logMessage(const char * format, ...);
41 FILE * GetLogFile() const {return log;}
50 const bool graphicsEnabled;
53 const bool allowIllegalMoves;
59 const Piece::Colour reveal;
62 static bool gameCreated;
67 const bool printBoard;
74 class FileController : public Controller
77 FileController(const Piece::Colour & newColour, FILE * newFile) : Controller(newColour, "file"), file(newFile) {}
78 virtual ~FileController() {}
80 virtual void Message(const char * string) {} //Don't send messages
81 virtual MovementResult QuerySetup(const char * opponentName, std::string setup[]);
82 virtual MovementResult QueryMove(std::string & buffer);
83 virtual bool Valid() const {return file != NULL;}