diff --git a/examples/flatland_2_0_example.py b/examples/flatland_2_0_example.py index 7ed5d27c3f2c3ed2660251dd7d54fe0b823e3568..0099b1cd88c2939ea3c4a04b308792a1403d716b 100644 --- a/examples/flatland_2_0_example.py +++ b/examples/flatland_2_0_example.py @@ -33,7 +33,7 @@ env = RailEnv(width=50, rail_generator=sparse_rail_generator(num_cities=9, # Number of cities in map (where train stations are) min_node_dist=12, # Minimal distance of nodes node_radius=4, # Proximity of stations to city center - seed=12, # Random seed + seed=0, # Random seed grid_mode=False, max_inter_city_rails=2, tracks_in_city=5, diff --git a/flatland/envs/rail_generators.py b/flatland/envs/rail_generators.py index d1911d4b6519710f4817270b9623ca00bc64f1cc..f5e377f8606813f8ba7cb4eee3012f62e3013dd1 100644 --- a/flatland/envs/rail_generators.py +++ b/flatland/envs/rail_generators.py @@ -736,11 +736,11 @@ def sparse_rail_generator(num_cities=5, min_node_dist=20, node_radius=2, direction += 1 continue - # If no closest neighbour was found look for the next one clock wise to avoid connecting to previous node - tmp_direction = (direction + 1) % 4 + # If no closest neighbour was found look at the neighbouring connections + tmp_direction = (direction - 1) % 4 while neighb_idx is None: neighb_idx = neighbours[tmp_direction] - tmp_direction = (tmp_direction - 1) % 4 + tmp_direction = (tmp_direction + 1) % 4 connected_to_city.append(neighb_idx) for tmp_out_connection_point in connection_points[current_node][direction]: