本文整理汇总了Python中captureAgents.CaptureAgent.registerTeam方法的典型用法代码示例。如果您正苦于以下问题:Python CaptureAgent.registerTeam方法的具体用法?Python CaptureAgent.registerTeam怎么用?Python CaptureAgent.registerTeam使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类captureAgents.CaptureAgent
的用法示例。
在下文中一共展示了CaptureAgent.registerTeam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registerInitialState
# 需要导入模块: from captureAgents import CaptureAgent [as 别名]
# 或者: from captureAgents.CaptureAgent import registerTeam [as 别名]
def registerInitialState(self, 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 15 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.
'''
if self.red:
CaptureAgent.registerTeam(self, gameState.getRedTeamIndices())
else:
CaptureAgent.registerTeam(self, gameState.getBlueTeamIndices())
#Agents try to go to center with top or bottom bias
self.goToCenter(gameState)
示例2: registerInitialState
# 需要导入模块: from captureAgents import CaptureAgent [as 别名]
# 或者: from captureAgents.CaptureAgent import registerTeam [as 别名]
def registerInitialState(self, 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 15 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.
'''
# Sets if agent is on red team or not
if self.red:
CaptureAgent.registerTeam(self, gameState.getRedTeamIndices())
else:
CaptureAgent.registerTeam(self, gameState.getBlueTeamIndices())
# Get how large the game space is
self.x, self.y = gameState.getWalls().asList()[-1]
# Legal positions are positions without walls
self.legalPositions = [p for p in gameState.getWalls().asList(False) if p[1] > 1]
self.walls = list(gameState.getWalls())
# Chokes contains choke points on our side of game space
self.chokes = []
# Offsets for how far away from middle our ghosts should sit if an invader is detected
# but cannot be seen for some reason
if self.red:
xAdd = -3
else:
xAdd = 4
# Find all choke points of interest
for i in range(self.y):
if not self.walls[self.x/2+xAdd][i]:
self.chokes.append(((self.x/2+xAdd), i))
if self.index == max(gameState.getRedTeamIndices()) or self.index == max(gameState.getBlueTeamIndices()):
x, y = self.chokes[3*len(self.chokes)/4]
else:
x, y = self.chokes[1*len(self.chokes)/4]
self.goalTile = (x, y)
# beliefs is used to infere the position of enemy agents using noisey data
global beliefs
beliefs = [util.Counter()] * gameState.getNumAgents()
# All beliefs begin with the agent at its inital position
for i, val in enumerate(beliefs):
if i in self.getOpponents(gameState):
beliefs[i][gameState.getInitialAgentPosition(i)] = 1.0
#Agents inital move towards the centre with a bias for either the top or the bottom
self.goToCenter(gameState)