flatland.core.distance_map module#
- class flatland.core.distance_map.AbstractDistanceMap(agents: List[EnvAgent], waypoint_init: Callable[[UnderlyingConfigurationType], UnderlyingWaypointType])[source]#
Bases:
Generic[UnderlyingTransitionMapType,UnderlyingDistanceMapType,UnderlyingConfigurationType,UnderlyingWaypointType]- get_shortest_paths(max_depth: int | None = None, agent_handle: int | None = None) Dict[int, List[UnderlyingWaypointType] | None][source]#
Computes the shortest path for each agent to its target and the action to be taken to do so. The paths are derived from a DistanceMap.
If there is no path (rail disconnected), the path is given as None. The agent state (moving or not) and its speed are not taken into account
- example:
agent_fixed_travel_paths = get_shortest_paths(env.distance_map, None, agent.handle) path = agent_fixed_travel_paths[agent.handle]
Parameters#
self : reference to the distance_map max_depth : max path length, if the shortest path is longer, it will be cut agent_handle : if set, the shortest path for agent.handle will be returned, otherwise for all agents
Returns#
Dict[int, Optional[List[WalkingElement]]]