Get n_city from RailEnv


It’s possible to get number of generated cities from RailEnv?
As far as I understood from rail_generator signature, sometimes it’s not possible to generate number of cities you ask for.

Hey @kirill_ershov, no, annoyingly you can’t get that number from the environment with the current version.

This is an open bug in Flatland:

A dirty way may be to use the formula for the max number of timesteps?

# flatland/envs/
timedelay_factor = 4
alpha = 2
max_episode_steps = int(timedelay_factor * alpha * (rail.width + rail.height + num_agents / len(city_positions)))

You know the values of rail.width, rail.height and num_agents so you could recover len(city_positions) :grimacing:

1 Like