當前位置: 首頁>>代碼示例>>Python>>正文


Python Agent.update方法代碼示例

本文整理匯總了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)
開發者ID:NoRxn,項目名稱:PathFinder,代碼行數:37,代碼來源:World.py


注:本文中的Agent.Agent.update方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。