def chooseAction(self, gameState): # we're blue for now if self.red: return choice(gameState.getLegalActions(self.index)) enemyIndices = [] if self.red: enemyIndices = gameState.getBlueTeamIndices() else: enemyIndices = gameState.getRedTeamIndices() if self.inferenceModule.distributions == None: self.inferenceModule.initializeDistributions(gameState, enemyIndices) for agentIndex in enemyIndices: self.inferenceModule.observe(gameState, self.index, agentIndex) self.inferenceModule.elapseTime(gameState, agentIndex) # this is just to get the distribution in a format that is displayable distrToDisplay = [] for i in xrange(gameState.getNumAgents()): if i in self.inferenceModule.distributions.keys(): distrToDisplay.append(self.inferenceModule.distributions[i]) else: distrToDisplay.append(None) self.displayDistributionsOverPositions(distrToDisplay) return DefensiveReflexAgent.chooseAction(self, gameState)
def getBestAction(self, state): return DefensiveReflexAgent.chooseAction(self, state)