Moving Flatland 2 code to Flatland 3 - Common changes
Moving Flatland 2 code to Flatland 3 - Common changes¶
1. Line Generators¶
schedule_generators are now renamed to
This is because Flatland 2 had no concept of a timetable for allowed departures of expected arrival times.
line_generators now generate the data that
schedule_generators used to (start-end station pairs for agents).
If your code used
sparse_schedule_generator, replace it with
sparse_line_generator, the behaviour slightly varies, but it should be similar for the most high level code.
2. Change from
sparse_rail_generator has an input parameter
max_rails_in_city replaced with
max_rail_pairs_in_city. You can replace the original input number that was being used by dividing it by 2. This is to ensure every city has a minimum of 2 rails which we keep as a constraint for balancing inflow and outflow of the trains.
3. Waiting State¶
Flatland 3 introduces a
WAITING state for every train, in which all actions will be ignored if the elapsed timesteps is less than the train’s earliest departure.
4. Change from
env.step function has been refactored to include a state machine for better intepretability of the functions for people who like to read and hack the code.
RailAgentStatus and the attribute
agent.moving is now changed to
This can now be accessed as
agent.state instead of
5. Removal of
Flatland 2 used to represent malfunctions in a dictionary
agent.malfunction_data, this is now moved to the class
agent.malfucntion_handler which keeps the same behvaior but refactored for better readability.
Train speed and partial fractional position in cells was stored in the dictionary
agent.speed_data, this is now moved to the class
agent.speed_counter, which keeps the same functionality but refactored as a counter instead of fractional position.
6. Removal of
complex generator classes¶
The genrator classes
random_schedule_generator are now deprecated and removed from the environment. Please use
7. Safe minimum env size is 30x30¶
While its possible to generate smaller environments for exploration and understanding, we recommend using 30x30 as the minimum size to satisfy new constrains on the rail generation.