`complex_rail_generator` generates invalid start position for trains on `env.reset()`
The first map generated by complex_rail_generator
generates valid starting positions for trains, but resetting the env generates invalid starting positions for the trains, i.e. the trains are not on the tracks.
Code to reproduce (in jupyter)
import datetime
from PIL import Image
import matplotlib.pyplot as plt
%matplotlib inline
from flatland.envs.generators import (
complex_rail_generator,
random_rail_generator,
empty_rail_generator,
)
from flatland.envs.rail_env import RailEnv
from flatland.utils.rendertools import RenderTool
number_of_agents = 2
width, height = 8, 8
env = RailEnv(
width=width,
height=height,
rail_generator=complex_rail_generator(
nr_start_goal=6, nr_extra=30, min_dist=10, max_dist=99999, seed=0
),
number_of_agents=number_of_agents,
)
renderer = RenderTool(env)
# reset generates invalid starting positions
for _ in range(3):
start_ts = datetime.datetime.now()
env.reset()
renderer.renderEnv(show=False)
display(Image.fromarray(renderer.gl.getImage()))
print(f"Generating map took {datetime.datetime.now() - start_ts}")
Tested with flatland 0.2.
Edited by stefan_otte