X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fmanager%2Fcontroller.cpp;h=20b79aa101328775c265e471db403817adce8b65;hp=1b0a35d0dca0b1972b78a095b710f077a90cd293;hb=ac335e7c423d067effae82cc80db518f896271b9;hpb=1a03b2543b67f0551e62babec4cd119f1e0e4640 diff --git a/judge/manager/controller.cpp b/judge/manager/controller.cpp index 1b0a35d..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; @@ -80,16 +88,22 @@ MovementResult Controller::MakeMove(string & buffer) if (query != MovementResult::OK) return query; + /* + //Removed 3/01/12 NO_MOVE now not allowed, SURRENDER is undocumented and not necessary if (buffer == "NO_MOVE") { 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); @@ -138,8 +152,11 @@ MovementResult Controller::MakeMove(string & buffer) case MovementResult::OK: buffer += " OK"; break; - case MovementResult::VICTORY: - buffer += " FLAG"; + case MovementResult::VICTORY_FLAG: + buffer += " VICTORY_FLAG"; + break; + case MovementResult::VICTORY_ATTRITION: + buffer += " VICTORY_ATTRITION"; break; case MovementResult::KILLS: buffer += " KILLS "; @@ -182,3 +199,24 @@ MovementResult Controller::MakeMove(string & buffer) return moveResult; } + +/** + * 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 +} +