当前位置: 首页>>代码示例>>Python>>正文


Python Terrain.get_percentage_of_maze_explored方法代码示例

本文整理汇总了Python中terrain.Terrain.get_percentage_of_maze_explored方法的典型用法代码示例。如果您正苦于以下问题:Python Terrain.get_percentage_of_maze_explored方法的具体用法?Python Terrain.get_percentage_of_maze_explored怎么用?Python Terrain.get_percentage_of_maze_explored使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在terrain.Terrain的用法示例。


在下文中一共展示了Terrain.get_percentage_of_maze_explored方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Robot

# 需要导入模块: from terrain import Terrain [as 别名]
# 或者: from terrain.Terrain import get_percentage_of_maze_explored [as 别名]

#.........这里部分代码省略.........
        return rotation, movement

    def deal_with_dead_end(self, x, y, heading):
        # 1) Move back one step
        rotation = 0
        movement = -1

        # 2) Get reference to cell
        cell = self.terrain.grid[x][y]
        # 3) Place imaginary wall behind the robot before exiting location
        reverse_direction = dir_reverse[heading]
        index = self.terrain.get_index_of_wall(reverse_direction)
        cell.imaginary_walls[index] = 1

        # 4) Change the value of visited to signify dead end
        cell.visited = 'x'
        cell.distance = WALL_VALUE

        # 5) Update imaginary walls and distances
        self.terrain.update_imaginary_walls(x, y, cell.imaginary_walls)

        return rotation, movement

    def should_end_exploring(self, x, y):
        """
        The robot should end exploring in all these cases:
        - It has already explored more than 90% of the cells
        - It has already taken 30 steps (in the exploration phase)
        - It has reached the center of the maze (again)
        - It has reached the starting location (again)
        """

        # Check for % of cells covered
        if self.terrain.get_percentage_of_maze_explored() > 80:
            return True

        if self.consecutive_explored_cells >= 3:
            return True

        # Check for number of steps
        if self.steps_exploring > 15:
            return True

        # Check for center of the maze:
        if self.is_at_center_of_the_maze(x, y):
            return True

        if self.is_at_starting_position(x, y):
            return True

        return False

    def final_round(self, x, y, heading, sensors):
        """
        Returns the correct rotation and maximum numbers of steps that
         the robot can take to optimize the score while staying on track
        """

        rotation = None
        movement = None
        current_distance = self.terrain.grid[x][y].distance

        adj_distances, adj_visited = \
            self.terrain.get_adj_info(
                x, y, heading, sensors, False)
开发者ID:RodrigoVillatoro,项目名称:machine_learning_projects,代码行数:69,代码来源:robot.py


注:本文中的terrain.Terrain.get_percentage_of_maze_explored方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。