X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fcontroller.cpp;h=e31c1eefb992962a02bf5e4094df8e210a310a21;hp=3a78e9b902e82349e789f6fce0a46ef70782143f;hb=HEAD;hpb=38c6e9b9fc245ca5e6e6cee2806cb64dcbd34e35 diff --git a/judge/manager/controller.cpp b/judge/manager/controller.cpp index 3a78e9b..e31c1ee 100644 --- a/judge/manager/controller.cpp +++ b/judge/manager/controller.cpp @@ -62,6 +62,14 @@ MovementResult Controller::Setup(const char * opponentName) { return MovementResult::BAD_RESPONSE; //You need to include a flag! } + + //Added 9/04/12 - Check all pieces that can be placed are placed + for (int ii = 0; ii <= (int)(Piece::BOMB); ++ii) + { + if (usedUnits[ii] != Piece::maxUnits[ii]) + return MovementResult::BAD_RESPONSE; //You must place ALL possible pieces + } + return MovementResult::OK; @@ -87,13 +95,16 @@ MovementResult Controller::MakeMove(string & buffer) buffer += " OK"; return MovementResult::OK; } + */ + //Restored SURRENDER 9/04/12, because... it kind of seems necessary? if (buffer == "SURRENDER") { buffer += " OK"; return MovementResult::SURRENDER; } - */ - + + + int x; int y; string direction=""; stringstream s(buffer); s >> x; @@ -101,6 +112,9 @@ MovementResult Controller::MakeMove(string & buffer) s >> direction; + + + Board::Direction dir; if (direction == "UP") { @@ -120,6 +134,7 @@ MovementResult Controller::MakeMove(string & buffer) } else { + if (Game::theGame->allowIllegalMoves) return MovementResult::OK; else @@ -189,4 +204,23 @@ MovementResult Controller::MakeMove(string & buffer) } +/** + * Fixes the name of the controller + * Should be called AFTER the constructor, since it modifies the name string, which might be used in the constructor + */ +void Controller::FixName() +{ + for (unsigned int ii=0; ii < name.size(); ++ii) + { + if (name[ii] == ' ') + { + name.erase(ii); //Just erase everything after the first whitespace + break; + } + } + //This is kind of hacky; I added it so that I could pass arguments to the AIs + //Because simulate.py doesn't like extra arguments showing up in the AI name at the end of the game (its fine until then) + //So I'll just remove them, after they have been passed! What could possibly go wrong? + // - Last entry in Sam Moore's diary, 2012 +}