moveList.append({"unit":unit, "direction":bestScore[0], "score":bestScore[1]})
- if len(moveList) == 0:
+ if len(moveList) <= 0:
print "NO_MOVE"
return True
def CalculateScore(self, attacker, defender, path):
p = move(attacker.x, attacker.y, path[0], 1)
-
+ if p[0] < 0 or p[0] >= len(self.board) or p[1] < 0 or p[1] >= len(self.board[p[0]]):
+ return -100.0
total = 0.0
count = 0.0
for blue in agents: #against each other agent, playing as blue
if red == blue:
continue #Exclude battles against self
- gameNumber += 1
- gameID = str(roundNumber) + "." + str(gameNumber)
+
+
for i in range(1, nGames/2 + 1):
+ gameNumber += 1
+ gameID = str(roundNumber) + "." + str(gameNumber)
#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(gameID)
+ errorLog = [logDirectory + "error/" + red["name"] + "."+str(gameID), logDirectory + "error/" + blue["name"] + "."+str(gameID)]
outline = os.popen(managerPath + " -o " + logFile + " -T " + str(timeoutValue) + " " + red["path"] + " " + blue["path"], "r").read()
results = outline.split(' ')