X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fcontroller.cpp;h=20b79aa101328775c265e471db403817adce8b65;hp=3a78e9b902e82349e789f6fce0a46ef70782143f;hb=ac335e7c423d067effae82cc80db518f896271b9;hpb=38c6e9b9fc245ca5e6e6cee2806cb64dcbd34e35 diff --git a/judge/manager/controller.cpp b/judge/manager/controller.cpp index 3a78e9b..20b79aa 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,12 +95,15 @@ 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); @@ -189,4 +200,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 +}