X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fgame.cpp;h=5282ec0d1158edfe59e49a30c6cc7f531d419890;hp=f25c9f381cfcc62f25eaa951b3928bd34e44468d;hb=476617a8222c8c56404c12a65dd75c55b8019542;hpb=341297b4dce9528d54fe9dceeff0d6dc33f70abe diff --git a/judge/manager/game.cpp b/judge/manager/game.cpp index f25c9f3..5282ec0 100644 --- a/judge/manager/game.cpp +++ b/judge/manager/game.cpp @@ -43,7 +43,7 @@ Game::Game(const char * redPath, const char * bluePath, const bool enableGraphic fprintf(stderr, "BLUE! (blue: \"%s\")\n", bluePath); exit(EXIT_FAILURE); } - logMessage("Game initialised.\n"); +// logMessage("Game initialised.\n"); } Game::Game(const char * fromFile, const bool enableGraphics, double newStallTime, const bool allowIllegal, FILE * newLog, const Piece::Colour & newReveal, int newMaxTurns, bool newPrintBoard, double newTimeoutTime) : red(NULL), blue(NULL), turn(Piece::RED), theBoard(10,10), graphicsEnabled(enableGraphics), stallTime(newStallTime), allowIllegalMoves(allowIllegal), log(newLog), reveal(newReveal), turnCount(0), input(NULL), maxTurns(newMaxTurns), printBoard(newPrintBoard), timeoutTime(newTimeoutTime) @@ -479,7 +479,7 @@ MovementResult Game::Play() - logMessage("Messaging red with \"START\"\n"); +// logMessage("Messaging red with \"START\"\n"); red->Message("START"); @@ -771,6 +771,9 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) { Network * redNetwork = NULL; Network * blueNetwork = NULL; + //To allow for running two network controllers (I don't know why you would, but beside the point...) use two ports + static const int port1 = 4560; + static const int port2 = 4561; if (redPath[0] == '@') { @@ -789,7 +792,7 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) if (network == NULL) { logMessage("Creating server for red AI... "); - redNetwork = new Server(); + redNetwork = new Server(port1); logMessage("Successful!\n"); } @@ -797,7 +800,7 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) { network = (const char*)(network+1); logMessage("Creating client for red AI... "); - redNetwork = new Client(network); + redNetwork = new Client(network, port2); logMessage("Connected to address %s\n", network); } @@ -825,7 +828,7 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) if (network == NULL) { logMessage("Creating server for blue AI... "); - blueNetwork = new Server(); + blueNetwork = new Server(port2); logMessage("Successful!\n"); } @@ -833,7 +836,7 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) { network = (const char*)(network+1); logMessage("Creating client for blue AI... "); - blueNetwork = new Client(network); + blueNetwork = new Client(network, port1); logMessage("Connected to address %s\n", network); } logMessage(" (Blue's responses will be received over the connection)\n"); @@ -855,6 +858,8 @@ void Game::MakeControllers(const char * redPath, const char * bluePath) red = new NetworkSender(Piece::RED, red, blueNetwork); logMessage(" (Red's responses will be copied over the connection)\n"); } + + red->FixName(); blue->FixName(); }