X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fsimulator%2Fsimulate.py;h=5daafb7dde7182899d54eb6462fdeb075485930d;hp=aead755beaafc63361e2b9a6375d6791ee7ca236;hb=4dcf57563f5f4503ac70ec87158ae21bb9d2951d;hpb=1a03b2543b67f0551e62babec4cd119f1e0e4640 diff --git a/judge/simulator/simulate.py b/judge/simulator/simulate.py index aead755..5daafb7 100755 --- a/judge/simulator/simulate.py +++ b/judge/simulator/simulate.py @@ -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: @@ -226,7 +228,7 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): 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() + outline = os.popen(managerPath + " -o " + logFile + " -T " + str(timeoutValue) + " " + red["path"] + " " + blue["path"], "r").read() results = outline.split(' ') if len(results) != 6: @@ -234,8 +236,8 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): sys.stdout.write("Garbage output! \"" + outline + "\"\n") red["INTERNAL_ERROR"].append((blue["name"], gameID, scores["INTERNAL_ERROR"][0])) blue["INTERNAL_ERROR"].append((red["name"], gameID, scores["INTERNAL_ERROR"][0])) - red["ALL"].append((blue["name"], gameID, scores["INTERNAL_ERROR"][0], "INTERNAL_ERROR")) - blue["ALL"].append((red["name"], gameID, scores["INTERNAL_ERROR"][0], "INTERNAL_ERROR")) + red["ALL"].append((blue["name"], gameID, scores["INTERNAL_ERROR"][0], "INTERNAL_ERROR", "RED")) + blue["ALL"].append((red["name"], gameID, scores["INTERNAL_ERROR"][0], "INTERNAL_ERROR", "BLUE")) managerErrors += 1 else: @@ -326,10 +328,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 +356,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(" " + str(agent["ALL"][index][1]) + " "+agent["ALL"][index][0] + " " + agent["ALL"][index][4] + " " + agent["ALL"][index][3] + " " + str(agent["ALL"][index][2]) + " " + str(agent["score"][len(agent["score"])-index -2]) + " \n") agentFile.write("\n")