Fixed bug in simulate.py + hacky fix for bug in vixen
[progcomp2012.git] / judge / simulator / simulate.py
index b84a525..7235624 100755 (executable)
@@ -27,6 +27,8 @@ baseDirectory = "../.." #Base directory for results, logs, agents
 nGames = 2 #Number of games played by each agent against each opponent. Half will be played as RED, half as BLUE. If nGames <= 1, then no games will be played (useful for dry run?)
 nRounds = 1
 
+timeoutValue = 2
+
 if len(sys.argv) >= 2:
        nRounds = int(sys.argv[1])
 if len(sys.argv) >= 3:
@@ -219,14 +221,17 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
                for blue in agents: #against each other agent, playing as blue
                        if red == blue:
                                continue #Exclude battles against self
-                       gameNumber += 1
-                       gameID = str(roundNumber) + "." + str(gameNumber)
+                       
+                       
                        for i in range(1, nGames/2 + 1):
+                               gameNumber += 1
+                               gameID = str(roundNumber) + "." + str(gameNumber)
                                #Play a game and read the result. Note the game is logged to a file based on the agent's names
                                if verbose:
                                        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)
-                               outline = os.popen(managerPath + " -o " + logFile + " " + red["path"] + " " + blue["path"], "r").read()
+                               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()
                                results = outline.split(' ')
                        
                                if len(results) != 6:
@@ -326,10 +331,10 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
                print "RESULTS FOR ROUND " + str(roundNumber)
 
        #totalFile = open(resultsDirectory+"total.scores", "w") #Recreate the file
-               for agent in agents:    
+               #for agent in agents:   
                #totalFile.write(agent["name"] + " " + str(agent["totalScore"]) +"\n") #Write the total scores in descending order
                #if verbose:
-                               print "Agent: " + str(agent)
+               #               print "Agent: " + str(agent)
        
 
        if verbose:
@@ -354,9 +359,9 @@ for roundNumber in range(totalRounds, totalRounds + nRounds):
 
                for index in range(0, len(agent["ALL"])):
                        if agent["ALL"][index][4] == "RED":
-                               logFile = logDirectory + "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:
-                               logFile = logDirectory + "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")
                

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