X-Git-Url: https://git.ucc.asn.au/?p=progcomp2012.git;a=blobdiff_plain;f=judge%2Fsimulator%2Fsimulate.py;h=a7a138d2059b3f0c7d74b10fc305e65c4f686b82;hp=b055945b67ae47e0e5cda478f920efe49baf964f;hb=b1c6f5bee1c544be8b04d16d1bce9a66688df0c3;hpb=7c42b4b7e5ed6e423f0c023ad6e8a2aa47a4f081 diff --git a/judge/simulator/simulate.py b/judge/simulator/simulate.py index b055945..a7a138d 100755 --- a/judge/simulator/simulate.py +++ b/judge/simulator/simulate.py @@ -51,7 +51,7 @@ if len(sys.argv) >= 5: #Score dictionary - Tuple is of the form: (end score, other score, other result) where end is the player on whose turn the result occurs, other is the other player, other result indicates what to record the outcome as for the other player. -scores = {"VICTORY":(3,1, "DEFEAT"), "DEFEAT":(1,3, "VICTORY"), "SURRENDER":(0,3, "VICTORY"), "DRAW":(2,2, "DRAW"), "DRAW_DEFAULT":(1,1, "DRAW_DEFAULT"), "ILLEGAL":(-1,2, "DEFAULT"), "DEFAULT":(2,-1, "ILLEGAL"), "BOTH_ILLEGAL":(-1,-1, "BOTH_ILLEGAL"), "INTERNAL_ERROR":(0,0, "INTERNAL_ERROR"), "BAD_SETUP":(0,0,"BAD_SETUP")} +scores = {"VICTORY":(0.3,0.1, "DEFEAT"), "DEFEAT":(0.1,0.3, "VICTORY"), "SURRENDER":(0,0.3, "VICTORY"), "DRAW":(0.2,0.2, "DRAW"), "DRAW_DEFAULT":(0.1,0.1, "DRAW_DEFAULT"), "ILLEGAL":(-0.1,0.2, "DEFAULT"), "DEFAULT":(0.2,-0.1, "ILLEGAL"), "BOTH_ILLEGAL":(-0.1,-0.1, "BOTH_ILLEGAL"), "INTERNAL_ERROR":(0,0, "INTERNAL_ERROR"), "BAD_SETUP":(0,0,"BAD_SETUP")} #Verbose - print lots of useless stuff about what you are doing (kind of like matches talking on irc...) @@ -152,6 +152,9 @@ if verbose: if verbose: print "Preparing .html results files..." +#BACKUP THE RESULTS DIRECTORY GOD DAMMIT +os.system("mkdir .before_round"+str(totalRounds)+"_BACKUP/; cp " + resultsDirectory+"*" + " .before_round"+str(totalRounds)+"_BACKUP/") + if os.path.exists(resultsDirectory + "index.html") == True: os.remove(resultsDirectory + "index.html") #Delete the file @@ -206,7 +209,7 @@ for agent in agents: agentFile.write(line) line = oldFile.readline() values = line.split(' ') - agent["totalScore"] += int(values[2].strip()) + agent["totalScore"] += float(values[2].strip()) agent["Wins"] += int(values[5].strip()) agent["Losses"] += int(values[8].strip()) agent["Draws"] += int(values[11].strip()) @@ -258,7 +261,8 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): 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)] #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() + outline = os.popen(managerPath + " -m 1000 -o " + logFile + " -T " + str(timeoutValue) + " \"" + red["path"] + "\" \"" + blue["path"] + "\" 2>> " + logFile+".stderr", "r").read() + #os.system("mv tmp.mp4 " + logFile + ".mp4") #If there were no errors, get rid of the stderr file