flatland.core.grid.grid4_astar module

class flatland.core.grid.grid4_astar.AStarNode(pos: Tuple[int, int], parent=None)[source]

Bases: object

A node class for A* Pathfinding

update_if_better(self, other)[source]
flatland.core.grid.grid4_astar.a_star(grid_map:flatland.core.transition_map.GridTransitionMap, start:Tuple[int, int], end:Tuple[int, int], a_star_distance_function:Callable[[Tuple[int, int], Tuple[int, int]], float]=<function Vec2dOperations.get_manhattan_distance at 0x7f2d29c36d08>, avoid_rails=False, respect_transition_validity=True, forbidden_cells:List[Tuple[int, int]]=None) → List[Tuple[int, int]][source]
Parameters:
  • avoid_rails
  • grid_map – Grid Map where the path is found in
  • start – Start positions as (row,column)
  • end – End position as (row,column)
  • a_star_distance_function – Define the distance function to use as heuristc: -get_euclidean_distance -get_manhattan_distance -get_chebyshev_distance
  • respect_transition_validity – Whether or not a-star respect allowed transitions on the grid map. - True: Respects the validity of transition. This generates valid paths, of no path if it cannot be found - False: This always finds a path, but the path might be illegal and thus needs to be fixed afterwards
  • forbidden_cells – List of cells where the path cannot pass through. Used to avoid certain areas of Grid map
Returns:

IF a path is found a ordered list of al cells in path is returned