flatland.envs.distance_map module#

class flatland.envs.distance_map.DistanceMap(agents: List[EnvAgent], env_height: int, env_width: int)[source]#

Bases: object

get() ndarray[source]#

Get the distance map

get_shortest_paths(max_depth: int | None = None, agent_handle: int | None = None) Dict[int, List[Waypoint] | 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 cutted agent_handle : if set, the shortest for agent.handle will be returned , otherwise for all agents

Returns#

Dict[int, Optional[List[WalkingElement]]]

reset(agents: List[EnvAgent], rail: RailGridTransitionMap)[source]#

Reset the distance map

set(distance_map: ndarray)[source]#

Set the distance map