diff --git a/progcomp/agents/asmodeus/info b/progcomp/agents/asmodeus/info index da91d830a67e9e96788e9848eecce89a9c1f1158..62e9c51b26acde05b0a8177502f738e6b5478d85 100644 --- a/progcomp/agents/asmodeus/info +++ b/progcomp/agents/asmodeus/info @@ -1 +1,4 @@ asmodeus.py +Sam Moore +python +Sample AI - Improves basic_python Scores moves based on paths towards enemy units and known combat outcomes, chooses highest scoring move. diff --git a/progcomp/agents/basic_cpp/info b/progcomp/agents/basic_cpp/info index ee1b50227ad4c3f773ca5ef851a418de2cb7f23d..dd61e4acd54d14eb9cab155a5ec3ff8eebf8b943 100644 --- a/progcomp/agents/basic_cpp/info +++ b/progcomp/agents/basic_cpp/info @@ -1 +1,4 @@ basic_cpp +Sam Moore +C++ +Sample AI - Provides classes that obey the manager program's protocol, and stores the state of the board and pieces, but only makes randomised moves. diff --git a/progcomp/agents/basic_python/info b/progcomp/agents/basic_python/info index 926072639e970ba55973f0fb39dc4c390f3b44dc..93fbaa2037eb383a0e1f98a1c41d0c02ad94878c 100644 --- a/progcomp/agents/basic_python/info +++ b/progcomp/agents/basic_python/info @@ -1 +1,4 @@ basic_python.py +Sam Moore +python +Sample AI - Provides classes that obey the manager program's protocol, and stores the state of the board and pieces, but only makes randomised moves. diff --git a/progcomp/agents/vixen/info b/progcomp/agents/vixen/info index 424358b77a4b081613cb9d1ce7a397559b1fccab..56945f648fce0b8af418a26aabf12cd1c40197f0 100644 --- a/progcomp/agents/vixen/info +++ b/progcomp/agents/vixen/info @@ -1 +1,4 @@ vixen.py +Sam Moore +python +Sample AI - An improvement on asmodeus' score optimisation. Considers probabilities for unknown enemy units, and sums scores for paths with common first move. diff --git a/progcomp/judge/simulator/Makefile b/progcomp/judge/simulator/Makefile index 423751646d18cbfff26d2224dd81cbdfe47a4295..6296c3a2726429e70973e927480f72c05923b771 100644 --- a/progcomp/judge/simulator/Makefile +++ b/progcomp/judge/simulator/Makefile @@ -3,8 +3,8 @@ # Used for building/removing results BASEDIR = /home/sam/Documents/progcomp2012/progcomp -RESULTSDIR = /home/sam/Documents/progcomp2012/progcomp/results -LOGDIR = /home/sam/Documents/progcomp2012/progcomp/log +RESULTSDIR = /home/sam/Documents/progcomp2012/progcomp/web/results +LOGDIR = /home/sam/Documents/progcomp2012/progcomp/web/log AGENTSDIR = /home/sam/Documents/progcomp2012/progcomp/agents MANAGER = /home/sam/Documents/progcomp2012/progcomp/judge/manager/stratego @@ -13,3 +13,4 @@ MANAGER = /home/sam/Documents/progcomp2012/progcomp/judge/manager/stratego clean: rm -r -f $(RESULTSDIR) rm -r -f $(LOGDIR) + diff --git a/progcomp/judge/simulator/simulate.py b/progcomp/judge/simulator/simulate.py index 9b79194e686c043a3ff47059eb4367c9b0111c25..aead755beaafc63361e2b9a6375d6791ee7ca236 100755 --- a/progcomp/judge/simulator/simulate.py +++ b/progcomp/judge/simulator/simulate.py @@ -39,8 +39,8 @@ if len(sys.argv) >= 6: print "Useage: " +sys.argv[0] + " [nRounds=1] [nGames=10] [baseDirectory=\""+baseDirectory+"\"] [managerPath=baseDirectory+\"/judge/manager/stratego\"]" sys.exit(1) -resultsDirectory = baseDirectory+"/results/" #Where results will go (results are in the form of text files of agent names and scores) -logDirectory = baseDirectory+"/log/" #Where log files go (direct output of manager program) +resultsDirectory = baseDirectory+"/web/results/" #Where results will go (results are in the form of text files of agent names and scores) +logDirectory = baseDirectory+"/web/log/" #Where log files go (direct output of manager program) agentsDirectory = baseDirectory+"/agents/" #Where agents are found (each agent has its own subdirectory within this directory) managerPath = baseDirectory+"/judge/manager/stratego" #Path to the executable that plays the games if len(sys.argv) >= 5: @@ -65,16 +65,22 @@ if os.path.exists(managerPath) == False: if os.path.exists(resultsDirectory) == False: os.mkdir(resultsDirectory) #Make the results directory if it didn't exist -''' - Obselete older version doesn't work with new .html files -#Identify the round number by reading the results directory -totalRounds = len(os.listdir(resultsDirectory)) + 1 -if totalRounds > 1: - totalRounds -= 1 -''' -totalRounds = 1 -#TODO: Fix this bit! + +#Identify the round number by reading from the "info" file in the results directory, if it doesn't exist then start at round 1. +if os.path.exists(resultsDirectory+"info") == False: + totalRounds = 1 +else: + info = open(resultsDirectory+"info", "r") + totalRounds = int(info.readline().strip()) + info.close() + os.remove(resultsDirectory+"info") + +info = open(resultsDirectory+"info", "w") +info.write(str(totalRounds + nRounds) + "\n") +info.close() + + if os.path.exists(logDirectory) == False: os.mkdir(logDirectory) #Make the log directory if it didn't exist @@ -106,7 +112,18 @@ for name in agentNames: sys.stdout.write(" Invalid! (No \"info\" file found)\n") continue - agentExecutable = agentsDirectory+name+"/"+(open(agentsDirectory+name+"/info").readline().strip()) + infoFile = open(agentsDirectory+name+"/info", "r") + agentExecutable = agentsDirectory+name+"/"+(infoFile.readline().strip()) + author = infoFile.readline().strip() + language = infoFile.readline().strip() + description = "" + while True: + line = infoFile.readline() + if len(line) > 0: + description += line + else: + break + infoFile.close() if os.path.exists(agentExecutable) == False: if verbose: @@ -119,7 +136,7 @@ for name in agentNames: #Convert array of valid names into array of dictionaries containing information about each agent #I'm starting to like python... - agents.append({"name":name, "path":agentExecutable, "score":[0], "VICTORY":[], "DEFEAT":[], "DRAW":[], "ILLEGAL":[], "DEFAULT":[], "INTERNAL_ERROR":[], "SURRENDER":[], "DRAW_DEFAULT":[], "BOTH_ILLEGAL":[], "BAD_SETUP":[], "ALL":[], "totalScore":0, "Wins":0, "Losses":0, "Draws":0, "Illegal":0, "Errors":0}) + agents.append({"name":name, "path":agentExecutable, "author":author, "language":language, "description":description, "score":[0], "VICTORY":[], "DEFEAT":[], "DRAW":[], "ILLEGAL":[], "DEFAULT":[], "INTERNAL_ERROR":[], "SURRENDER":[], "DRAW_DEFAULT":[], "BOTH_ILLEGAL":[], "BAD_SETUP":[], "ALL":[], "totalScore":0, "Wins":0, "Losses":0, "Draws":0, "Illegal":0, "Errors":0}) if len(agents) == 0: print "Couldn't find any agents! Check paths (Edit this script) or generate \"info\" files for agents." @@ -131,23 +148,25 @@ if verbose: #Prepare the pretty .html files if they don't exist if verbose: print "Preparing .html results files..." -htmlDir = resultsDirectory + "pretty/" -if os.path.exists(htmlDir) == False: - os.mkdir(htmlDir) -if os.path.exists(htmlDir) == False: - print "Couldn't create directory \""+htmlDir+"\"." - sys.exit(1) + for agent in agents: - if os.path.exists(htmlDir+agent["name"] + ".html") == False: - agentFile = open(htmlDir+agent["name"] + ".html", "w") - agentFile.write("\n\n " + agent["name"] + " results\n\n\n

Results for " + agent["name"]+"

\n\n\n") + if os.path.exists(resultsDirectory+agent["name"] + ".html") == False: + agentFile = open(resultsDirectory+agent["name"] + ".html", "w") + agentFile.write("\n\n " + agent["name"] + " overview\n\n\n

Overview for " + agent["name"]+"

\n") + agentFile.write("\n") + agentFile.write("\n") + agentFile.write("\n") + agentFile.write("
Name Author Language
"+agent["name"]+" "+agent["author"]+" "+agent["language"]+"
\n"); + + agentFile.write("

Description

\n") + agentFile.write("

" + agent["description"] + "

\n") agentFile.close() - os.rename(htmlDir+agent["name"] + ".html", "tmpfile") + os.rename(resultsDirectory+agent["name"] + ".html", "tmpfile") oldFile = open("tmpfile", "r") - agentFile = open(htmlDir+agent["name"] + ".html", "w") + agentFile = open(resultsDirectory+agent["name"] + ".html", "w") line = oldFile.readline() while line != "": #if verbose: @@ -169,7 +188,7 @@ for agent in agents: line = oldFile.readline() if verbose: - print "Prepared results file \"" + htmlDir+agent["name"] + ".html\"." + print "Prepared results file \"" + resultsDirectory+agent["name"] + ".html\"." oldFile.close() agentFile.close() os.remove("tmpfile") @@ -206,7 +225,7 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): #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(i) + logFile = logDirectory + "round"+str(roundNumber) + "/"+red["name"]+".vs."+blue["name"]+"."+str(gameID) outline = os.popen(managerPath + " -o " + logFile + " " + red["path"] + " " + blue["path"], "r").read() results = outline.split(' ') @@ -317,7 +336,7 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): print "Updating pretty .html files... " for agent in agents: - agentFile = open(htmlDir + agent["name"]+".html", "a") + agentFile = open(resultsDirectory + agent["name"]+".html", "a") agentFile.write("

Round " + str(roundNumber) + "

\n") agentFile.write("

Round Overview

\n") agentFile.write("\n") @@ -325,13 +344,20 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): agentFile.write("\n") agentFile.write("
"+str(agent["score"][0])+" "+str(len(agent["VICTORY"]) + len(agent["DEFAULT"]))+" "+str(len(agent["DEFEAT"]) + len(agent["SURRENDER"]))+" "+str(len(agent["DRAW"]) + len(agent["DRAW_DEFAULT"]))+" "+str(len(agent["ILLEGAL"]) + len(agent["BOTH_ILLEGAL"]) + len(agent["BAD_SETUP"]))+" " +str(len(agent["INTERNAL_ERROR"]))+"
\n") + agentFile.write("

Round "+str(roundNumber) + " Scoreboard

\n") agentFile.write("

Detailed

\n") agentFile.write("\n") agentFile.write("\n") + + for index in range(0, len(agent["ALL"])): - agentFile.write("\n") + if agent["ALL"][index][4] == "RED": + logFile = logDirectory + "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]) + agentFile.write("\n") agentFile.write("
Game ID Opponent Played as Outcome Score Accumulated Score
" + 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]) + "
" + 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") agent["totalScore"] += agent["score"][0] @@ -347,10 +373,12 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): agentFile.write(" "+str(agent["totalScore"])+" "+str(agent["Wins"])+" "+str(agent["Losses"])+" "+str(agent["Draws"])+" "+str(agent["Illegal"])+" " +str(agent["Errors"])+" \n") agentFile.write("\n") + + agentFile.close() #Update round file - roundFile = open(htmlDir + "round"+str(roundNumber)+".html", "w") + roundFile = open(resultsDirectory + "round"+str(roundNumber)+".html", "w") roundFile.write("\n\n Round " +str(roundNumber)+ " Overview \n\n\n") roundFile.write("

Round " +str(roundNumber)+ " Overview

\n") roundFile.write("\n") @@ -358,7 +386,9 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): agents.sort(key = lambda e : e["score"][0], reverse=True) for agent in agents: roundFile.write("\n") - roundFile.write("
"+agent["name"] + " " + str(agent["score"][0]) + " " + str(agent["totalScore"]) + "
\n\n\n\n\n") + roundFile.write("\n") + roundFile.write("

Current Scoreboard

\n") + roundFile.write("\n\n\n\n") roundFile.close() @@ -368,17 +398,17 @@ for roundNumber in range(totalRounds, totalRounds + nRounds): if verbose: print "Finalising .html files... " for agent in agents: - agentFile = open(htmlDir + agent["name"]+".html", "a") + agentFile = open(resultsDirectory + agent["name"]+".html", "a") #Write the "total" statistics agentFile.write("\n\n\n\n") agentFile.close() - if os.path.exists(htmlDir + "total.html") == True: - os.remove(htmlDir + "total.html") #Delete the file + if os.path.exists(resultsDirectory + "total.html") == True: + os.remove(resultsDirectory + "total.html") #Delete the file -totalFile = open(htmlDir + "total.html", "w") +totalFile = open(resultsDirectory + "total.html", "w") totalFile.write("\n\n Total Overview \n\n\n") totalFile.write("

Total Overview

\n") totalFile.write("\n") @@ -386,7 +416,15 @@ totalFile.write("\n") agents.sort(key = lambda e : e["totalScore"], reverse=True) for agent in agents: totalFile.write("\n") -totalFile.write("
Name Total Score
"+agent["name"] + " " + str(agent["totalScore"]) + "
\n\n\n\n\n") +totalFile.write("\n") + +totalFile.write("

Round Summaries

\n") +totalFile.write("\n") +for i in range(1, totalRounds+1): + totalFile.write("\n") +totalFile.write("
Round " + str(i) + "
\n") + +totalFile.write("\n\n\n\n") totalFile.close()