[PATCH] Remove arguments, patch vixen, add hunter AI
[progcomp2012.git] / judge / manager / controller.cpp
index 1b0a35d..20b79aa 100644 (file)
@@ -62,6 +62,14 @@ MovementResult Controller::Setup(const char * opponentName)
        {
                return MovementResult::BAD_RESPONSE; //You need to include a flag!
        }
        {
                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;
 
 
        return MovementResult::OK;
 
@@ -80,16 +88,22 @@ MovementResult Controller::MakeMove(string & buffer)
        if (query != MovementResult::OK)
                return query;
 
        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;
        }
        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;
        }
        if (buffer == "SURRENDER")
        {
                buffer += " OK";
                return MovementResult::SURRENDER;
        }
+
+
        
        int x; int y; string direction="";
        stringstream s(buffer);
        
        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::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 ";
                        break;
                case MovementResult::KILLS:
                        buffer += " KILLS ";
@@ -182,3 +199,24 @@ MovementResult Controller::MakeMove(string & buffer)
        return moveResult;      
 
 }
        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
+}
+

UCC git Repository :: git.ucc.asn.au