コード例 #1
0
ファイル: robot.py プロジェクト: ScaleneTriangle/Micromouse
 def AStar_robot(self):
     """
     Perform a AStar search to find the optimal route based on the
     known maze 
     
     Note: Changing the weight of g (weight based on steps from start)
         in AStar caused the algorithm to get out of a stuck corner case.
         Should do something to modify cell.g if the same move is seen 
         multiple times in a short period. (3 in 5?)
     """
     search = AStar(self.maze_dim, self.current_maze, 
                    self.location, self.goal)
     # Build the internal AStar grid
     search.init_grid()
     # Find the optimal route
     search.process()
     # Return the list of moves necessary to reach the goal
     self.move_list = search.display_path(show=False)
     print(self.move_list)
     #print(self.move_list)
     # Return the move
     rotation, movement = self.move_direction(self.move_list.pop(0))
     return rotation, movement