5 #include "ai_controller.h"
6 #include "human_controller.h"
7 #include "network_controller.h"
12 * Class to manage the game
13 * Bit messy since I keep adding on parameters :P
18 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, const char * newImageOutput = "");
19 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, const char * newImageOutput = "");
24 void Wait(double wait);
26 Piece::Colour Setup(const char * redName, const char * blueName);
27 MovementResult CheckVictoryAttrition();
28 MovementResult Play();
29 void PrintEndMessage(const MovementResult & result);
32 static void HandleBrokenPipe(int signal);
33 void ReadUserCommand();
35 const Piece::Colour Turn() const {return turn;}
36 void ForceTurn(const Piece::Colour & newTurn) {turn = newTurn;}
37 int TurnCount() const {return turnCount;}
39 static Game * theGame;
40 static int Tokenise(std::vector<std::string> & buffer, std::string & str, char split = ' '); //Helper - Split a string into tokens
43 void MakeControllers(const char * redPath, const char * bluePath); //Create a controller based off a path
45 int logMessage(const char * format, ...);
46 static void PrintResults(const MovementResult & result, std::string & buffer);
47 FILE * GetLogFile() const {return log;}
56 const bool graphicsEnabled;
59 const bool allowIllegalMoves;
65 const Piece::Colour reveal;
68 static bool gameCreated;
73 const bool printBoard;
77 std::string imageOutput;
81 class FileController : public Controller
84 FileController(const Piece::Colour & newColour, FILE * newFile) : Controller(newColour, "file"), file(newFile) {}
85 virtual ~FileController() {}
87 virtual bool Message(const char * string) {return true;} //Don't send messages
88 virtual MovementResult QuerySetup(const char * opponentName, std::string setup[]);
89 virtual MovementResult QueryMove(std::string & buffer);
90 virtual bool Valid() const {return file != NULL;}
98 std::string itostr(int i);