def registerInitialState(self, gameState: GameState): """ This method handles the initial setup of the agent to populate useful fields (such as what team we're on). A distanceCalculator instance caches the maze distances between each pair of positions, so your agents can use: self.distancer.getDistance(p1, p2) IMPORTANT: This method may run for at most 5 seconds. """ ''' Make sure you do not delete the following line. If you would like to use Manhattan distances instead of maze distances in order to save on initialization time, please take a look at CaptureAgent.registerInitialState in captureAgents.py. ''' CaptureAgent.registerInitialState(self, gameState) ''' Your initialization code goes here, if you need any. ''' self.reverseRed = False self.reverseBlue = False self.finishQuarter = False self.goingEndgame = False
def registerInitialState(self, gameState: GameState): self.gridWall = gameState.getWalls() self.initialPosition = gameState.getAgentPosition(self.index) self.currPosition = self.initialPosition self.home = findHome(self.gridWall, self.initialPosition) if (gameState.getAgentPosition(self.index)[0] > (self.gridWall.width - 1) // 2): self.mapMiddlePoint = (round( (self.gridWall.width - 1) * 0.65), self.gridWall.height // 2) else: self.mapMiddlePoint = (round( (self.gridWall.width - 1) * 0.35), self.gridWall.height // 2) self.goingUp = True self.firstPatrolDone = True self.topChokePoint = self.mapMiddlePoint self.bottomChokePoint = self.mapMiddlePoint CaptureAgent.registerInitialState(self, gameState)
def registerInitialState(self, gameState: GameState): walls = gameState.getWalls() maxX, maxY = walls.asList()[-1] limitRegion = math.ceil(maxX/2) + 1 if gameState.isOnRedTeam(self.index): limitRegion -= 3 for y in range(0, maxY): if not gameState.hasWall(limitRegion, y): self.openBorder.append(Position(limitRegion, y)) self.enemiesIndices = gameState.getRedTeamIndices() if gameState.isOnRedTeam(self.index): self.enemiesIndices = gameState.getBlueTeamIndices() # for pos in self.openBorder: # print(pos) # print("\n") CaptureAgent.registerInitialState(self, gameState)
def registerInitialState(self, gameState: GameState): """ This method handles the initial setup of the agent to populate useful fields (such as what team we're on). A distanceCalculator instance caches the maze distances between each pair of positions, so your agents can use: self.distancer.getDistance(p1, p2) IMPORTANT: This method may run for at most 5 seconds. """ ''' Make sure you do not delete the following line. If you would like to use Manhattan distances instead of maze distances in order to save on initialization time, please take a look at CaptureAgent.registerInitialState in captureAgents.py. ''' CaptureAgent.registerInitialState(self, gameState) ''' Your initialization code goes here, if you need any. ''' self.minFoodxy = (0, 0) self.gridWall = gameState.getWalls() self.home = findHome(self.gridWall, gameState.getAgentPosition(self.index)) if (self.index in gameState.getRedTeamIndices()): # left side self.mapMiddlePoint = (self.gridWall.width // 2 - 2, self.gridWall.height // 2) self.foodInMouth = 0 else: # right side self.mapMiddlePoint = (self.gridWall.width // 2 + 2, self.gridWall.height // 2) self.foodInMouth = 0
def registerInitialState(self, gameState: GameState): CaptureAgent.registerInitialState(self, gameState)