flatland.envs.grid4_generators_utils module

Definition of the RailEnv environment and related level-generation functions.

Generator functions are functions that take width, height and num_resets as arguments and return a GridTransitionMap object.

flatland.envs.grid4_generators_utils.align_cell_to_city(city_center, city_orientation, cell)[source]

Alig all cells to face the city center along the city orientation @param city_center: Center needed for orientation @param city_orientation: Orientation of the city @param cell: Cell we would like to orient :@return: Orientation of cell towards city center along axis of city orientation

flatland.envs.grid4_generators_utils.connect_rail_in_grid_map(grid_map:flatland.core.transition_map.GridTransitionMap, start:Tuple[int, int], end:Tuple[int, int], rail_trans:flatland.core.grid.rail_env_grid.RailEnvTransitions, a_star_distance_function:Callable[[Tuple[int, int], Tuple[int, int]], float]=<function Vec2dOperations.get_manhattan_distance at 0x7f2d29c36d08>, flip_start_node_trans:bool=False, flip_end_node_trans:bool=False, respect_transition_validity:bool=True, forbidden_cells:List[Tuple[int, int]]=None, avoid_rail=False) → List[Tuple[int, int]][source]
Creates a new path [start,end] in grid_map.grid, based on rail_trans, and

returns the path created as a list of positions. :param avoid_rail: :param rail_trans: basic rail transition object :param grid_map: grid map :param start: start position of rail :param end: end position of rail :param flip_start_node_trans: make valid start position by adding dead-end, empty start if False :param flip_end_node_trans: make valid end position by adding dead-end, empty end if False :param respect_transition_validity: Only draw rail maps if legal rail elements can be use, False, draw line without respecting rail transitions. :param a_star_distance_function: Define what distance function a-star should use :param forbidden_cells: cells to avoid when drawing rail. Rail cannot go through this list of cells :return: List of cells in the path

flatland.envs.grid4_generators_utils.connect_straight_line_in_grid_map(grid_map:flatland.core.transition_map.GridTransitionMap, start:Tuple[int, int], end:Tuple[int, int], rail_trans:flatland.core.grid.rail_env_grid.RailEnvTransitions) → List[Tuple[int, int]][source]

Generates a straight rail line from start cell to end cell. Diagonal lines are not allowed :param rail_trans: :param grid_map: :param start: Cell coordinates for start of line :param end: Cell coordinates for end of line :return: A list of all cells in the path

flatland.envs.grid4_generators_utils.fix_inner_nodes(grid_map:flatland.core.transition_map.GridTransitionMap, inner_node_pos:Tuple[int, int], rail_trans:flatland.core.grid.rail_env_grid.RailEnvTransitions)[source]

Fix inner city nodes by connecting it to its neighbouring parallel track :param grid_map: :param inner_node_pos: inner city node to fix :param rail_trans: :return: