X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;ds=sidebyside;f=judge%2Fsimulator%2Fsimulate.py;h=a7a138d2059b3f0c7d74b10fc305e65c4f686b82;hb=52489d9b9b2d7633f9b7caaed0ed1ea40972032b;hp=b84a525d50ae8dc765b662f86da26ba506e4b743;hpb=fda21e69af7d794fa2280ce613144e5bbd8e1f5e;p=progcomp2012.git diff --git a/judge/simulator/simulate.py b/judge/simulator/simulate.py index b84a525..a7a138d 100755 --- a/judge/simulator/simulate.py +++ b/judge/simulator/simulate.py @@ -10,6 +10,7 @@ Now (sortof) generates .html files to display results in a prettiful manner. + THIS FILE IS TERRIBLE author Sam Moore (matches) [SZM] website http://matches.ucc.asn.au/stratego @@ -27,6 +28,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: @@ -48,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":(1,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...) @@ -125,7 +128,7 @@ for name in agentNames: 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 @@ -149,6 +152,29 @@ 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 +totalFile = open(resultsDirectory + "index.html", "w") +totalFile.write("\n
\nPlease wait for the rounds to finish. You can view the current progress by watching the Log Files
") +if totalRounds > 1: + totalFile.write("Round " + str(i) + " |