+ sys.stdout.write(" Invalid! (File \""+agentExecutable+"\" does not exist!)\n")
+ continue
+
+
+ if verbose:
+ sys.stdout.write(" Valid! (To run: \""+agentExecutable+"\")\n")
+ agents.append([name, agentExecutable, 0])
+
+ if len(agents) == 0:
+ print "Couldn't find any agents! Check paths (Edit this script) or generate \"info\" files for agents."
+ sys.exit(0)
+ if verbose:
+ print "Total: " + str(len(agents)) + " valid agents found (From "+str(len(agentNames))+" possibilities)"
+ print ""
+ print "Commencing ROUND " + str(roundNumber) + " combat! This could take a while... "
+
+
+ normalGames = 0
+ draws = 0
+ aiErrors = 0
+ managerErrors = 0
+ #This double for loop simulates a round robin, with each agent getting the chance to play as both red and blue against every other agent.
+ for red in agents: #for each agent playing as red,
+ for blue in agents: #against each other agent, playing as blue
+ if red == blue:
+ continue #Exclude battles against self
+ for i in range(1, nGames/2 + 1):
+ #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[0]+"\" and \""+blue[0]+"\" playing game " + str(i) + "/"+str(nGames/2) + "... ")
+ logFile = logDirectory + "round"+str(roundNumber) + "/"+red[0]+"_vs_"+blue[0]+"_"+str(i)
+ outline = os.popen(managerPath + " -o " + logFile + " " + red[1] + " " + blue[1], "r").read()
+ results = outline.split(' ')
+
+ if len(results) != 6:
+ if verbose:
+ sys.stdout.write("Garbage output! \"" + outline + "\"\n")
+ managerErrors += 1
+ else:
+ if results[1] == "RED":
+ red[2] += scores[results[2]][0]
+ blue[2] += scores[results[2]][1]
+ normalGames += 1
+ elif results[1] == "BLUE":
+ red[2] += scores[results[2]][1]
+ blue[2] += scores[results[2]][0]
+ normalGames += 1
+ elif results[1] == "BOTH":
+ red[2] += scores[results[2]][0]
+ blue[2] += scores[results[2]][1]
+ red[2] += scores[results[2]][1]
+ blue[2] += scores[results[2]][0]
+ draws += 1
+ if verbose:
+ sys.stdout.write(" Result \"")
+ for ii in range(1, len(results)):
+ sys.stdout.write(results[ii].strip())
+ if ii < (len(results) - 1):
+ sys.stdout.write(" ")
+ sys.stdout.write("\"\n")
+