本文整理匯總了Python中Agent.Agent.update方法的典型用法代碼示例。如果您正苦於以下問題:Python Agent.update方法的具體用法?Python Agent.update怎麽用?Python Agent.update使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Agent.Agent
的用法示例。
在下文中一共展示了Agent.update方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: World
# 需要導入模塊: from Agent import Agent [as 別名]
# 或者: from Agent.Agent import update [as 別名]
class World(Widget):
def __init__(self, settings):
super().__init__()
self.settings = settings
# Generate Obstacles
self.obstacles = []
for i in range(self.settings.NUM_OBSTACLES):
self.obstacles.append((randint(0, self.settings.GRID_WIDTH - 1) * self.settings.CELL_SIZE, randint(0, self.settings.GRID_HEIGHT - 1) * self.settings.CELL_SIZE))
# Generate goal
self.goal = (randint(0, self.settings.GRID_WIDTH - 1) * self.settings.CELL_SIZE, randint(0, self.settings.GRID_HEIGHT - 1) * self.settings.CELL_SIZE)
while self.goal in self.obstacles:
self.goal = (randint(0, self.settings.GRID_WIDTH - 1) * self.settings.CELL_SIZE, randint(0, self.settings.GRID_HEIGHT - 1) * self.settings.CELL_SIZE)
# Create the agent
self.agent = Agent(self.settings, self.canvas, self.goal, self.obstacles, self.settings.HEURISTIC)
def draw(self):
with self.canvas:
# Draw obstactles
Color(*self.settings.OBSTACLE_COLOR)
for ob in self.obstacles:
Rectangle(pos=ob, size=(self.settings.CELL_SIZE, self.settings.CELL_SIZE))
# Draw goal
Color(*self.settings.GOAL_COLOR)
Rectangle(pos=self.goal, size=(self.settings.CELL_SIZE, self.settings.CELL_SIZE))
def update(self, dt):
with self.canvas:
self.agent.update(dt)