flatland.env_generation.env_generator module#
- flatland.env_generation.env_generator.env_generator(n_agents=7, x_dim=30, y_dim=30, n_cities=2, max_rail_pairs_in_city=4, grid_mode=False, max_rails_between_cities=2, malfunction_duration_min=20, malfunction_duration_max=50, malfunction_interval=540, speed_ratios=None, seed=42, obs_builder_object=None, acceleration_delta=1.0, braking_delta=-1.0, rewards: Rewards | None = None, effects_generator: EffectsGenerator[RailEnv] | None = None) Tuple[RailEnv, Dict, Dict] [source]#
Create an env with a given spec using sparse_rail_generator. Defaults are taken from Flatland 3 Round 2 Test_0, see `Environment Configurations <https://flatland.aicrowd.com/challenges/flatland3/envconfig.html`_. Parameters name come from metadata.csv in debug-environments.zip
Parameters#
- n_agents: int
number of agents
- x_dim: int
number of columns
- y_dim: int
number of rows
- n_cities: int
Max number of cities to build. The generator tries to achieve this numbers given all the parameters. Goes into sparse_rail_generator.
- max_rail_pairs_in_city: int
Number of parallel tracks in the city. This represents the number of tracks in the train stations. Goes into sparse_rail_generator.
- grid_mode: bool
How to distribute the cities in the path, either equally in a grid or random. Goes into sparse_rail_generator.
- max_rails_between_cities: int
Max number of rails connecting to a city. This is only the number of connection points at city boarder.
- malfunction_duration_min: int
Minimal duration of malfunction. Goes into ParamMalfunctionGen.
- malfunction_duration_max: int
Max duration of malfunction. Goes into ParamMalfunctionGen.
- malfunction_interval: int
Inverse of rate of malfunction occurrence. Goes into ParamMalfunctionGen.
- speed_ratios: Dict[float, float]
Speed ratios of all agents. They are probabilities of all different speeds and have to add up to 1. Goes into sparse_line_generator. Defaults to {1.0: 0.25, 0.5: 0.25, 0.33: 0.25, 0.25: 0.25}.
- seed: int
Initiate random seed generators. Goes into reset.
- obs_builder_object: Optional[ObservationBuilder]
Defaults to TreeObsForRailEnv(max_depth=3, predictor=ShortestPathPredictorForRailEnv(max_depth=50))
Returns#
- RailEnv
The generated environment reset with the given seed.
- observationsDict
Initial observations from reset()
- infoDict
Initial infos from reset()