Tweaking manager/simulate.py, updating manual and webpage
authorSam Moore <[email protected]>
Sat, 3 Mar 2012 07:42:55 +0000 (15:42 +0800)
committerSam Moore <[email protected]>
Sat, 3 Mar 2012 07:42:55 +0000 (15:42 +0800)
You can now pass arguments to your AI through the manager program.
Simply include the path to the AI and arguments in quotation marks.

EG:
./stratego "../../agents/foo/bar --debug" ../../agents/other/agent

simulate.py was making broken links to log files, fixed.

Logging of stderr! If anything is printed to stderr, it is all saved in logfilename.stderr by simulate.py

Tried to make the manual page better, probably failed.

Updated webpage since we have now changed the date.

Also tried to fix vixen again, haven't tested.

agents/vixen/vixen.py
judge/manager/controller.cpp
judge/manager/controller.h
judge/manager/game.cpp
judge/manager/program.cpp
judge/simulator/simulate.py
web/doc/manager_manual.txt
web/index.html

index a4010b1..e4dee3f 100755 (executable)
@@ -22,7 +22,6 @@ from path import *
 class Vixen(BasicAI):
        " Python based AI, improves upon Asmodeus by taking into account probabilities, and common paths "
        def __init__(self):
 class Vixen(BasicAI):
        " Python based AI, improves upon Asmodeus by taking into account probabilities, and common paths "
        def __init__(self):
-               #sys.stderr.write("Vixen initialised...\n")
                BasicAI.__init__(self)
                
                
                BasicAI.__init__(self)
                
                
@@ -58,7 +57,9 @@ class Vixen(BasicAI):
                                scores[path[0]] += self.CalculateScore(unit, target, path)
 
                        bestScore = sorted(scores.items(), key = lambda e : e[1], reverse=True)[0]
                                scores[path[0]] += self.CalculateScore(unit, target, path)
 
                        bestScore = sorted(scores.items(), key = lambda e : e[1], reverse=True)[0]
-                       moveList.append({"unit":unit, "direction":bestScore[0], "score":bestScore[1]})
+                       if bestScore[1] > -100.0:
+                               moveList.append({"unit":unit, "direction":bestScore[0], "score":bestScore[1]})
+                       
                        
 
                if len(moveList) <= 0:
                        
 
                if len(moveList) <= 0:
@@ -87,7 +88,7 @@ class Vixen(BasicAI):
        def CalculateScore(self, attacker, defender, path):
                p = move(attacker.x, attacker.y, path[0], 1)
                if p[0] < 0 or p[0] >= len(self.board) or p[1] < 0 or p[1] >= len(self.board[p[0]]):
        def CalculateScore(self, attacker, defender, path):
                p = move(attacker.x, attacker.y, path[0], 1)
                if p[0] < 0 or p[0] >= len(self.board) or p[1] < 0 or p[1] >= len(self.board[p[0]]):
-                       return -100.0
+                       return -1000.0
 
                total = 0.0
                count = 0.0
 
                total = 0.0
                count = 0.0
index 3a78e9b..d268792 100644 (file)
@@ -189,4 +189,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
+}
 
 
index 5aa6364..069ccd6 100644 (file)
@@ -34,6 +34,8 @@ class Controller
 
                const Piece::Colour colour; 
 
 
                const Piece::Colour colour; 
 
+               virtual void FixName(); //Should be called after setup, sets the name of the controller
+
                std::string name;
 
 
                std::string name;
 
 
index ea7a7c9..5282ec0 100644 (file)
@@ -858,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 = new NetworkSender(Piece::RED, red, blueNetwork);
                logMessage("    (Red's responses will be copied over the connection)\n");
        }
+
+       red->FixName(); blue->FixName();
        
 }
 
        
 }
 
index 031d411..2d09a51 100644 (file)
@@ -6,7 +6,8 @@
 
 #include "thread_util.h"
 #include "program.h"
 
 #include "thread_util.h"
 #include "program.h"
-
+#include <vector>
+#include <string.h>
 
 using namespace std;
 
 
 using namespace std;
 
@@ -22,6 +23,43 @@ using namespace std;
  */
 Program::Program(const char * executablePath) : input(NULL), output(NULL), pid(0), paused(false)
 {
  */
 Program::Program(const char * executablePath) : input(NULL), output(NULL), pid(0), paused(false)
 {
+       
+               
+       
+       vector<char*> args;
+       if (executablePath[0] != '"')
+               args.push_back((char*)executablePath);
+       else
+               args.push_back((char*)(executablePath)+1);
+       char * token = NULL;
+       do
+       {
+               token = strstr(args[args.size()-1], " ");
+               if (token == NULL)
+                       break;
+
+               *token = '\0';
+               do
+               {
+                       ++token;
+                       if (*token == '"')
+                               *token = '\0';
+               }
+               while (*token != '\0' && iswspace(*token));
+
+               if (*token != '\0' && !iswspace(*token))
+               {
+                       args.push_back(token);
+               }
+               else
+                       break;
+       }
+       while (token != NULL);
+
+       char **  arguments = new char*[args.size()+2];
+       for (unsigned int i=0; i < args.size(); ++i)
+               arguments[i] = args[i];
+
        //See if file exists and is executable...
        if (access(executablePath, X_OK) != 0)
        {
        //See if file exists and is executable...
        if (access(executablePath, X_OK) != 0)
        {
@@ -51,7 +89,7 @@ Program::Program(const char * executablePath) : input(NULL), output(NULL), pid(0
                                
 
                if (access(executablePath, X_OK) == 0) //Check we STILL have permissions to start the file
                                
 
                if (access(executablePath, X_OK) == 0) //Check we STILL have permissions to start the file
-                       execl(executablePath, executablePath, (char*)(NULL)); ///Replace process with desired executable
+                       execv(executablePath,arguments); ///Replace process with desired executable
                
                fprintf(stderr, "Program::Program - Could not run program \"%s\"!\n", executablePath);
                exit(EXIT_FAILURE); //We will probably have to terminate the whole program if this happens
                
                fprintf(stderr, "Program::Program - Could not run program \"%s\"!\n", executablePath);
                exit(EXIT_FAILURE); //We will probably have to terminate the whole program if this happens
index 7235624..634e424 100755 (executable)
@@ -127,7 +127,7 @@ for name in agentNames:
                        break
        infoFile.close()
        
                        break
        infoFile.close()
        
-       if os.path.exists(agentExecutable) == False:
+       if os.path.exists(agentExecutable.split(" ")[0]) == False:
                if verbose:
                        sys.stdout.write(" Invalid! (Path: \""+agentExecutable+"\" does not exist!)\n")
                continue
                if verbose:
                        sys.stdout.write(" Invalid! (Path: \""+agentExecutable+"\" does not exist!)\n")
                continue
@@ -210,7 +210,7 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
 
        
        print "Commencing ROUND " + str(roundNumber) + " combat!"
 
        
        print "Commencing ROUND " + str(roundNumber) + " combat!"
-       print "Total: " + str(totalGames) + " games to be played. This could take a while... (Estimate 60s/game)"
+       print "Total: " + str(totalGames) + " games to be played. This could take a while..."
 
 
 
 
 
 
@@ -231,7 +231,12 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
                                        sys.stdout.write("Agents: \""+red["name"]+"\" and \""+blue["name"]+"\" playing game (ID: " + gameID + ") ... ")
                                logFile = logDirectory + "round"+str(roundNumber) + "/"+red["name"]+".vs."+blue["name"]+"."+str(gameID)
                                errorLog = [logDirectory + "error/" + red["name"] + "."+str(gameID), logDirectory + "error/" + blue["name"] + "."+str(gameID)]
                                        sys.stdout.write("Agents: \""+red["name"]+"\" and \""+blue["name"]+"\" playing game (ID: " + gameID + ") ... ")
                                logFile = logDirectory + "round"+str(roundNumber) + "/"+red["name"]+".vs."+blue["name"]+"."+str(gameID)
                                errorLog = [logDirectory + "error/" + red["name"] + "."+str(gameID), logDirectory + "error/" + blue["name"] + "."+str(gameID)]
-                               outline = os.popen(managerPath + " -o " + logFile + " -T " + str(timeoutValue) + " " + red["path"] + " " + blue["path"], "r").read()
+                               #Run the game, outputting to logFile; stderr of (both) AI programs is directed to logFile.stderr
+                               outline = os.popen(managerPath + " -o " + logFile + " -T " + str(timeoutValue) + " \"" + red["path"] + "\" \"" + blue["path"] + "\" 2>> " + logFile+".stderr", "r").read()
+                               
+                               #If there were no errors, get rid of the stderr file
+                               if os.stat(logFile+".stderr").st_size <= 0:
+                                       os.remove(logFile+".stderr")
                                results = outline.split(' ')
                        
                                if len(results) != 6:
                                results = outline.split(' ')
                        
                                if len(results) != 6:
@@ -287,46 +292,6 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
        if verbose:
                print "" 
        #We should now have complete score values.
        if verbose:
                print "" 
        #We should now have complete score values.
-               
-       '''
-               Obselete, non prettified results
-       if verbose:
-               sys.stdout.write("Creating raw results files for ROUND " + str(roundNumber) + "... ")
-
-       agents.sort(key = lambda e : e["score"], reverse=True) #Sort the agents based on score
-       
-       resultsFile = open(resultsDirectory+"round"+str(roundNumber)+".results", "w") #Create a file to store all the scores for this round
-       for agent in agents:
-               resultsFile.write(agent["name"] + " " + str(agent["score"]) +"\n") #Write the agent names and scores into the file, in descending order
-
-       if verbose:
-               sys.stdout.write(" Complete!\n")
-               sys.stdout.write("Updating total scores... ");
-       
-       #Now update the total scores
-       if os.path.exists(resultsDirectory+"total.scores"):
-               if verbose:
-                       sys.stdout.write(" Reading from \""+resultsDirectory+"total.scores\" to update scores... ")
-               totalFile = open(resultsDirectory+"total.scores", "r") #Try to open the total.scores file
-               for line in totalFile: #For all entries, 
-                       data = line.split(' ')
-                       for agent in agents:
-                               if agent["name"] == data[0]:
-                                       agent["totalScore"] = int(data[1]) + agent["score"][0] #Simply increment the current score by the recorded total score of the matching file entry
-                                       break
-               totalFile.close() #Close the file, so we can delete it
-               os.remove(resultsDirectory+"total.scores") #Delete the file
-               #Sort the agents again
-               agents.sort(key = lambda e : e["totalScore"], reverse=True)
-
-       else:
-               if verbose:
-                       sys.stdout.write(" First round - creating \""+resultsDirectory+"total.scores\"... ")
-       if verbose:
-               sys.stdout.write(" Complete!\n")
-               print "Finished writing results for ROUND " + str(roundNumber)
-               print ""
-       '''
        if verbose:     
                print "RESULTS FOR ROUND " + str(roundNumber)
 
        if verbose:     
                print "RESULTS FOR ROUND " + str(roundNumber)
 
@@ -359,9 +324,9 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
 
                for index in range(0, len(agent["ALL"])):
                        if agent["ALL"][index][4] == "RED":
 
                for index in range(0, len(agent["ALL"])):
                        if agent["ALL"][index][4] == "RED":
-                               logFile = "log/round"+str(roundNumber) + "/"+agent["name"]+".vs."+agent["ALL"][index][0]+"."+str(agent["ALL"][index][1])
+                               logFile = "../log/round"+str(roundNumber) + "/"+agent["name"]+".vs."+agent["ALL"][index][0]+"."+str(agent["ALL"][index][1])
                        else:
                        else:
-                               logFile = "log/round"+str(roundNumber) + "/"+agent["ALL"][index][0]+".vs."+agent["name"]+"."+str(agent["ALL"][index][1])
+                               logFile = "../log/round"+str(roundNumber) + "/"+agent["ALL"][index][0]+".vs."+agent["name"]+"."+str(agent["ALL"][index][1])
                        agentFile.write("<tr> <td> <a href="+logFile+">" + str(agent["ALL"][index][1]) + " </a> </td> <td> <a href="+agent["ALL"][index][0]+".html>"+agent["ALL"][index][0] + " </a> </td> <td> " + agent["ALL"][index][4] + " </td> <td> " + agent["ALL"][index][3] + " </td> <td> " + str(agent["ALL"][index][2]) + "</td> <td> " + str(agent["score"][len(agent["score"])-index -2]) + " </td> </tr> </th>\n")
                agentFile.write("</table>\n")
                
                        agentFile.write("<tr> <td> <a href="+logFile+">" + str(agent["ALL"][index][1]) + " </a> </td> <td> <a href="+agent["ALL"][index][0]+".html>"+agent["ALL"][index][0] + " </a> </td> <td> " + agent["ALL"][index][4] + " </td> <td> " + agent["ALL"][index][3] + " </td> <td> " + str(agent["ALL"][index][2]) + "</td> <td> " + str(agent["score"][len(agent["score"])-index -2]) + " </td> </tr> </th>\n")
                agentFile.write("</table>\n")
                
index c93927e..a19cd5d 100644 (file)
@@ -1,12 +1,17 @@
 NAME
        stratego - Interface to manage games of stratego between AI programs and/or human players
        
 NAME
        stratego - Interface to manage games of stratego between AI programs and/or human players
        
-WARNING
-       This program is still a work in progress. Consider it a Beta version.
+
 
 SYNOPSIS
        stratego {[-gpirb] [-o output_file ] [-t stall_time] [-T timeout_time] [-m max_turns] {red_player blue_player | -f input_file} | {-h | --help} }
 
 
 SYNOPSIS
        stratego {[-gpirb] [-o output_file ] [-t stall_time] [-T timeout_time] [-m max_turns] {red_player blue_player | -f input_file} | {-h | --help} }
 
+QUICK EXAMPLE - Play against a sample AI, using graphics, hiding the AI's pieces
+       stratego -g -b @human ../../agents/vixen/vixen.py
+
+QUICK EXAMPLE - Play two sample AI, using graphics, and a delay of 1 second between moves
+       stratego -g -t 1 ../../agents/vixen/vixen.py ../../agents/basic_python/basic_python.py
+
 DESCRIPTION
        stratego manages a game of Stratego. It stores the state of the board, and uses a simple protocol to interface with AI programs.
        By itself, stratego does not "play" the game. An external AI program must be used. stratego is intended to be used for the testing of 
 DESCRIPTION
        stratego manages a game of Stratego. It stores the state of the board, and uses a simple protocol to interface with AI programs.
        By itself, stratego does not "play" the game. An external AI program must be used. stratego is intended to be used for the testing of 
@@ -140,74 +145,263 @@ GAME RULES
                
 
 PROTOCOL
                
 
 PROTOCOL
-       In order to interface with stratego, an AI program must satisfy the following protocol. 
-       Each query is followed by a newline, and responses are expected to be followed with a newline.
-       The queries are recieved through stdin, and responses should be written to stdout.
-
-       "QUERY" describes the information sent to a program's stdin stream.
-       "RESPONSE" describes the form of the information that the program should immediately respond with, to stdout.
-       "CONFIRMATION" describes more information sent to the program's stdin stream, that the program should NOT respond to.
-       
-       1. SETUP
-               QUERY: YOUR_COLOUR OPPONENT_ID BOARD_WIDTH BOARD_HEIGHT
-
-               RESPONSE: 4 lines, each of length BOARD_WIDTH, of characters. Each character represents a piece. The characters are shown above.
+       WARNING: This is quite a wordy section. To avoid being scared off, try just copying a sample AI program. They obey the protocol already.
 
 
-               RED's pieces are placed at the top of the board, and BLUE's pieces are placed at the bottom.
-
-               An AI program does not have to place all 40 pieces, but must at least place the flag ('F').
-
-       2. TURN
-               QUERY:  START | CONFIRMATION
-                       BOARD_STATE
-
-                       On the first turn, "START" is printed to the Red player.
-                       On subsequent turns, the CONFIRMATION of the opponent's last turn is printed (see below).
-
-                       BOARD_STATE consists of a BOARD_HEIGHT lines of length BOARD_WIDTH characters, each of which represents a single piece
-                       as described in the GAME_RULES section. Each line ends with the newline character.
-                       
+       In order to interface with stratego, an AI program must satisfy the following protocol. 
+       The protocol has been grouped into several sections. It is suggested that you read and implement the below sections in order.
 
 
-               RESPONSE: X Y DIRECTION [MULTIPLIER=1] 
-                       X and Y are the coords (starting from 0) of the piece to move
-                       DIRECTION is either UP, DOWN, LEFT or RIGHT
-                       MULTIPLIER is optional and only valid for units of type Scout. Scouts may move through any number of unblocked squares
-                       in one direction.
+       In the "Synopsis" of each section, a line beginning with the three characters ">> " indicates information sent to the AI.
+                         a line beginning with the three characters "<< " indicates the form of the expected response.
+       Each line is always terminated with a new line character '\n'.
 
 
+       A vertical bar '|' indicates that the line may have the form shown either to the left, or the right.
+       Fields in square brackets '[' and ']' are optional. The default value will be shown within the brackets after a '=' character.
 
 
-               CONFIRMATION: X Y DIRECTION [MULTIPLIER=1] OUTCOME | QUIT [RESULT]
+       Any words preceeded by a '$' character are not to be interpreted literally; in the actual protocol, these words are replaced with information.
+       The information will not contain any whitespace unless otherwise stated.
+       The meaning of these words is explained below the "Synopsis" under the "Explanation" subheading for each section of the protocol.
 
 
-                       OUTCOME may be either OK, ILLEGAL, KILLS or DIES
-                               OK - Move was successful
-                               ILLEGAL - Move was not allowed. If stratego was not started with the -i switch, the game will end.
-                               KILLS ATTACKER_RANK DEFENDER_RANK - The piece moved into an occupied square and killed the defender.
-                               DIES ATTACKER_RANK DEFENDER_RANK - The piece moved into an occupied square and was killed by the defender.
+       Words not preceeded by a '$' character should be interpreted literally;
+               >> START
+       Means that "START", followed by a new line, is printed to the AI.
+       
+       
+       1. Setup
+               ---------------------------------------------------
+               Description
+               ---------------------------------------------------
+               Setup only occurs once; during the setup phase, AI are provided with information about their colour and opponent.
+               They must then respond with four lines detailing their setup.
+
+               Setup occurs before the first move; your AI should expect to recieve and respond to Setup messages immediately after starting.
+               Immediately after the setup phase, the AI should expect to recieve messages desribed by the Turn section of the protocol.
+               ---------------------------------------------------
+               Synopsis:
+               ---------------------------------------------------
+               >> $COLOUR $OPPONENT $WIDTH $HEIGHT
+               << $ROW1
+               << $ROW2
+               << $ROW3
+               << $ROW4
+               ---------------------------------------------------
+               Explanation:
+               ---------------------------------------------------
+
+               COLOUR - The colour assigned to the AI. Will be either "RED" or "BLUE"
+                           - Colour is important, because "RED" is always at the top of the board, and "BLUE" at the bottom.
+
+               OPPONENT - Your AI may identify its opponents through this string
+
+               WIDTH - The width of the board. This will always be 10
+               HEIGHT - The height of the board. This will always be 10
+
+               ROW1 - The highest row on the board of the AI's setup.
+                    - For RED, this is the back row, but for BLUE, it is the front row.
+               ROW2 - The next highest row
+               ROW3 - The next highest row
+               ROW4 - The lowest row on the board of the AI's setup
+                    - For RED, this is the front row, but for BLUE, it is the back row.
+       
+               Each row, ROW1 -> ROW4, should consist of WIDTH characters. Each character identifies a piece, as shown under "GAME RULES" above.
 
 
-                       QUIT will only be sent when the game is about to end.
-       3. END GAME
-               If the CONFIRMATION line is of the form:
-                       QUIT [RESULT]
-               Then the game is about to end.
+               An AI program does not have to place all 40 pieces, but must at least place the flag ('F').
+               However, note that an AI program with no mobile pieces will immediately lose.
+               ---------------------------------------------------
+               Example:
+               ---------------------------------------------------
+               >> RED ../../agents/vixen/vixen.py 10 10
+               << FB8sB479B8
+               << BB31555583
+               << 6724898974
+               << 967B669999
+
+               In this example, the AI will be playing as "RED". It's opponent is the "vixen" sample AI.
+               The board width and height will always be 10.
+               
+               The AI responds with a sensible setup for the "RED" player, putting the flag in the back corner.
+
+       2. Turn
+               ---------------------------------------------------
+               Description
+               ---------------------------------------------------
+               After the Setup phase, a number of Turns occur, until the game ends.
+
+               Warning: The game may end between turns, in which case a "QUIT" message is sent. 
+                       The "QUIT" message will be sent in place of the first line in the synopsis shown below.
+                       Read "3. End Game" below.
+               ---------------------------------------------------
+               Synopsis
+               ---------------------------------------------------
+               For the AI with colour "RED" only, and only on the very first turn:
+               >> START
+               >> $ROW1
+               >> $ROW2
+               >> $ROW3
+               >> $ROW4
+               >> $ROW5
+               >> $ROW6
+               >> $ROW7
+               >> $ROW8
+               >> $ROW9
+               >> $ROW10
+               << $X $Y $DIRECTION [$MULTIPLIER=1]
+               >> $X $Y $DIRECTION [$MULTIPLIER=1] $OUTCOME
+
+               For the AI with colour "RED" on every subsequent turn, and the AI with colour "BLUE" on all turns:
+               >> $LASTMOVE $OUTCOME
+               >> $ROW1
+               >> $ROW2
+               >> $ROW3
+               >> $ROW4
+               >> $ROW5
+               >> $ROW6
+               >> $ROW7
+               >> $ROW8
+               >> $ROW9
+               >> $ROW10
+               << $X $Y $DIRECTION [$MULTIPLIER=1]
+               >> $X $Y $DIRECTION [$MULTIPLIER=1] $OUTCOME | QUIT [$RESULT]
+               ---------------------------------------------------
+               Explanation:
+               ---------------------------------------------------
+
+               [Recieved data 1]
+
+               LASTMOVE - The last move made
+                        - That is, the move made by the opponent AI, immediately before this move
+                        - It is a direct copy of the opponent AI's response
+                        - On the very first turn, since no move has been made, "START" is printed to the RED AI
+               
+               OUTCOME - The interpretation of the move by the manager program; will be one of the following
+                       - Successful, uneventful move: "OK"
+                       - Illegal move: "ILLEGAL"
+                       - The moved piece attacked and destroyed an opponent piece: "KILLS $ATTACKER_RANK $DEFENDER_RANK"
+                               - ATTACKER_RANK and DEFENDER_RANK are the ranks of the attacking and defending piece respectively
+                       - The moved piece was destroyed by an opponent piece that it attacked: "DIES $ATTACKER_RANK $DEFENDER_RANK"
+                               - ATTACKER_RANK and DEFENDER_RANK are the ranks of the attacking and defending piece respectively
+                       - The moved piece attacked an opponent piece, and both pieces were destroyed: "BOTHDIE $ATTACKER_RANK $DEFENDER_RANK"
+                               - ATTACKER_RANK and DEFENDER_RANK are the ranks of the attacking and defending piece respectively
+
+               ROW1 -> ROW10 - The state of the board will be printed
+                             - Each line represents a row on the board, from the top downwards
+                             - The characters are as desribed above in "GAME RULES"
+                             - Enemy pieces will NOT be revealed, even if they have been involved in combat. They are always shown as '#'.
+                             - It is recommended that AI's rely on the LASTMOVE and OUTCOME results to keep state
+                             - Interpreting these lines is not necessary, or recommended
+                             - They still exist because I say so. GET OVER IT.
+
+               [Sent data]
+
+               X - The x coordinate of the piece to be moved. Ranges from 0 (zero) to 9 (nine) (left to right)
+               Y - The y coordinate of the piece to be moved. Ranges from 0 (zero) to 9 (nine) (top to bottom)
+               DIRECTION - The direction to move the piece in. May be either "LEFT", "RIGHT", "UP" or "DOWN"           
+               MULTIPLIER - Scouts may move more than one square.
+                          - To move a scout multiple spaces, print an integer indicating the number of spaces immediately after DIRECTION
+
+               [Recieved data 2]
+
+               The manager program will check the validity of the move, and respond by repeating it back to the AI, followed by OUTCOME.
+               OUTCOME is as described above.
+               ---------------------------------------------------
+               Example:
+               ---------------------------------------------------
+
+               First turn for RED:
+               -------------------
+               >> START
+               >> FB8sB479B8
+               >> BB31555583
+               >> 6724898974
+               >> 967B669999
+               >> ..++..++..
+               >> ..++..++..
+               >> ##########
+               >> ##########
+               >> ##########
+               >> ##########
+               << 0 3 DOWN
+               >> 0 3 DOWN OK
+               -------------------
+               Continuing from the Setup example, the RED AI is told to start, and then the board is printed.
+               Note that only RED's pieces are revealed. The obstacles are always in the same place, as shown.
+               Refer to the "GAME RULES" section for an explanation of each piece character.
+
+               The AI decides to move its scout (9) at (0,3) downwards by one place.
+               
+               The manager reports that this move was successful.
+
+               Second Turn for RED:
+               -------------------
+               >> 9 6 UP 3 BOTHDIE 9 9
+               >> FB8sB479B8
+               >> BB31555583
+               >> 6724898974
+               >> .67B66999.
+               >> 9.++..++..
+               >> ..++..++..
+               >> #########.
+               >> ##########
+               >> ##########
+               >> ##########
+               << 9 2 DOWN
+               >> 9 2 DOWN OK
+               -------------------
+               The next message recieved by the RED AI tells it that BLUE has moved its piece at (9,6) up by 3.
+               This brought the piece into contact with RED's scout (9) at (9,3)
+               Since BLUE's piece was also a scout (9), both pieces die, indicated by "BOTHDIE" followed by their ranks (9 and 9)
+               
+               The board is printed again. Note that RED's first move is reflected 
+                       (the scout (9) at (0,4)), and BLUE's last move (both (9,6) and (9,3) are now empty).
        
        
-               If present, RESULT will be a direct copy of the message to stdout described in the EXIT/OUTPUT section below.
+               The RED AI decides to move its major (4) at (9,2) downwards. This move is OK, because there is now nothing occupying (9,3).
+               ---------------------------------------------------
+               WARNING:
+               ---------------------------------------------------
+               It is recommended that you ignore the board state lines, except for the first turn.
+               Remember that an AI may not place all its pieces, so assuming its initial setup is a bad idea.
+               On subsequent turns, the board state lines provide no information that can't be processed from the move confirmation lines.
+               ---------------------------------------------------
+
+       3. End Game
+               ---------------------------------------------------
+               Description:
+               ---------------------------------------------------
+               A message of "QUIT" at any time signals to an AI that the game is about to end.
+               This will be sent immediately after an AI makes a move of the form "$X $Y $DIRECTION [$MULTIPLIER=1]" which ends the game
+               It may also be sent at any time in case of errors
                
                
+               The AI should immediately exit if a QUIT message is recieved.
+               ---------------------------------------------------
+               Synopsis:
+               ---------------------------------------------------
+               >> QUIT [RESULT]
+               ---------------------------------------------------
+               Explanation:
+               ---------------------------------------------------
+               RESULT - Usually not present; it may contain debug information if it is.
+               ---------------------------------------------------             
        
        
-       4. TIMEOUTS
+       4. Timeouts
+               ---------------------------------------------------
+               Description:
+               ---------------------------------------------------
                If a program fails to respond to a query, the game will end and that AI will be sent the ILLEGAL result.
                Human players are not subject to the timeout restriction.
                If a program fails to respond to a query, the game will end and that AI will be sent the ILLEGAL result.
                Human players are not subject to the timeout restriction.
-
-               Please see the information on the -T switch.
+               ---------------------------------------------------
+               Please see the information on the -T switch, and the "End Game" section above.
                
                        
 
 EXIT/OUTPUT
                
                        
 
 EXIT/OUTPUT
-       If the game ends due to a player either winning, or making an illegal move, stratego will print one of the following result messages to stdout.
+       If the game ends due to a player either winning, or making an illegal move, stratego will print one the following result message to stdout.
 
 
-       NAME COLOUR OUTCOME TURN_NUMBER OUTCOME RED_PIECE_VALUE BLUE_PIECE_VALUE
+       $NAME $COLOUR $OUTCOME $TURN  $RED_PIECE_VALUE $BLUE_PIECE_VALUE
 
        Where:
                NAME is the name of the player on whose turn the game ended,
 
        Where:
                NAME is the name of the player on whose turn the game ended,
+
                COLOUR is the colour of that player,
                COLOUR is the colour of that player,
+
                OUTCOME is one of the following:
                        VICTORY - The indicated player won
                        DEFEAT - The indicated player lost
                OUTCOME is one of the following:
                        VICTORY - The indicated player won
                        DEFEAT - The indicated player lost
@@ -216,10 +410,11 @@ EXIT/OUTPUT
                        DRAW_DEFAULT - The game ended in a draw because the maximum number of moves was exceeded
                        ILLEGAL - The indicated player loses due to an Illegal move/response
                        DEFAULT - The indicated player wins by default due to the other player making an Illegal move/response
                        DRAW_DEFAULT - The game ended in a draw because the maximum number of moves was exceeded
                        ILLEGAL - The indicated player loses due to an Illegal move/response
                        DEFAULT - The indicated player wins by default due to the other player making an Illegal move/response
-                       BOTH_ILLEGAL - Both players made an Illegal move/response. Usually occurs due to simultaneous setup errors, or bad executable paths.
-                       INTERNAL_ERROR - The game ended, even though it shouldn't have.
-                       
-               TURN_NUMBER is the number of turns that elapsed before the game ended
+                       BOTH_ILLEGAL - Both players made an Illegal move/response. Usually occurs due to simultaneous setup errors.                     
+                                       - May occur due to bad AI path names
+                       INTERNAL_ERROR - The game ended, even though it shouldn't have. 
+
+               TURN is the number of turns that elapsed before the game ended
 
                RED_PIECE_VALUE and BLUE_PIECE_VALUE are the summed piece values of the pieces of RED and BLUE respectively.
                Bombs and Flags are worth zero, and the ranked pieces (Spys -> Marshal) are worth (11 - rank).
 
                RED_PIECE_VALUE and BLUE_PIECE_VALUE are the summed piece values of the pieces of RED and BLUE respectively.
                Bombs and Flags are worth zero, and the ranked pieces (Spys -> Marshal) are worth (11 - rank).
@@ -281,5 +476,5 @@ NOTES
           irc://irc.ucc.asn.au #progcomp
 
 THIS PAGE LAST UPDATED
           irc://irc.ucc.asn.au #progcomp
 
 THIS PAGE LAST UPDATED
-       2/02/12 by Sam Moore
+       3/03/12 by Sam Moore
        
        
index beb0d2f..2a50bca 100644 (file)
 <p> <b> Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>
 
 <h2> Scoring and Results </h2>
 <p> <b> Warning:</b> AI programs <b>must</b> unbuffer stdin and stdout themselves. This is explained in the manual page, but I figured no one would read it. It is fairly simple to unbuffer stdin/stdout in C/C++ and python, I have not investigated other languages yet. </p>
 
 <h2> Scoring and Results </h2>
-<p> The competition will be a round robin, with every AI playing three (3) games against each possible opponent. A points system is used to score each AI, 3 points for a Win, 2 for a Draw, 1 for a Loss or -1 for an Illegal response (counts as a Win for the opponent). Scores accumulate between rounds. </p>
+<p> The competition will be a round robin, with every AI playing six (6) games against each possible opponent. A points system is used to score each AI, 3 points for a Win, 2 for a Draw, 1 for a Loss or -1 for an Illegal response (counts as a Win for the opponent). </p>
 <p> The winning AI will be the AI with the highest score after all games have been played. In the event of a tied score, the two highest scoring AI's will play one more round consisting of three games. If the scores are still tied, the official outcome will be a Draw. </p>
 <p> When the competition officially runs, results will appear <a href="results"/>here</a>. There may (or may not) be test results there now. </p> <p> 
 
 <p> The winning AI will be the AI with the highest score after all games have been played. In the event of a tied score, the two highest scoring AI's will play one more round consisting of three games. If the scores are still tied, the official outcome will be a Draw. </p>
 <p> When the competition officially runs, results will appear <a href="results"/>here</a>. There may (or may not) be test results there now. </p> <p> 
 
+<h2> Rounds and Events </h2>
+<ul>
+       <li> 10th March 2012 - Progcomp Day - Sam will be in the UCC clubroom to explain stuff and help people </li>
+       <li> ?? - Preliminary Round 1 - Gives entrants a chance to test their AI against others. Not worth any points. </li>
+       <li> ?? - Preliminary Round 2 - Scores less than 0 are not counted. Scores above 0 are weighted by 0.1 </li>
+       <li> 14th May 2012 - Round 1 - The main event. </li>
+       <li> ?? - Winner and prize announcement - The creator of the AI with the highest score is the winner </li>
+</ul>
+
 <h2> Sample AI Programs </h2>
 <p> Several sample AI programs are currently available. The sample programs can be downloaded from the <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository </a>
 <p> <b> Warning: </b> No guarantees are provided about the functioning of these programs. It is your own responsibility to ensure that your submission obeys the protocol correctly. If you have based your program off a sample, please double check that it obeys the protocol. </p>
 <h2> Sample AI Programs </h2>
 <p> Several sample AI programs are currently available. The sample programs can be downloaded from the <a href="http://git.ucc.asn.au/?p=progcomp2012.git;a=summary"/>git repository </a>
 <p> <b> Warning: </b> No guarantees are provided about the functioning of these programs. It is your own responsibility to ensure that your submission obeys the protocol correctly. If you have based your program off a sample, please double check that it obeys the protocol. </p>
@@ -66,7 +75,7 @@
 <p> <b> Code which attempts to comprimise the host machine, or interfere either directly or indirectly with the functioning of other programs will be disqualified. </b> </p>
 
 <h2> Dates </h2>
 <p> <b> Code which attempts to comprimise the host machine, or interfere either directly or indirectly with the functioning of other programs will be disqualified. </b> </p>
 
 <h2> Dates </h2>
-<p> The competition is now officially open. Submissions will be accepted until midday, Saturday the 10th of March, 2012. Results will be announced as soon as they are available (depending on the number of entries it may take several days to simulate the competition). </p>
+<p> The competition is now officially open. Submissions will be accepted until midday, Monday the 14th of May, 2012. Results will be announced as soon as they are available (depending on the number of entries it may take several days to simulate the competition). </p>
 
 <h2> Clarifications </h2>
 <ul>
 
 <h2> Clarifications </h2>
 <ul>
@@ -84,7 +93,7 @@
 <h2> Questions? </h2>
 <p> <a href="faq.html"/>Frequently Asked Questions</a> </p>
 <p> Please email matches@ or post to #progcomp with any questions not on that page. </p>
 <h2> Questions? </h2>
 <p> <a href="faq.html"/>Frequently Asked Questions</a> </p>
 <p> Please email matches@ or post to #progcomp with any questions not on that page. </p>
-<p> <b>Last webpage update: 07/01/12</b></p>
+<p> <b>Last webpage update: 03/02/12</b></p>
 </body>
 
 </html>
 </body>
 
 </html>

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