diff --git a/flatland/envs/generators.py b/flatland/envs/generators.py index 507597341ef85b9691b303c8919cff7061d81d3b..0b7ea708c27bb4cccef07cc71ef17d5759315952 100644 --- a/flatland/envs/generators.py +++ b/flatland/envs/generators.py @@ -961,8 +961,9 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation start = train_stations[current_start_node][start_station_idx] while (target[0], target[1]) in agents_target: target_station_idx = np.random.randint(len(train_stations[current_target_node])) - start_station_idx = np.random.randint(len(train_stations[current_start_node])) target = train_stations[current_target_node][target_station_idx] + while (start[0], start[1]) in agents_position: + start_station_idx = np.random.randint(len(train_stations[current_start_node])) start = train_stations[current_start_node][start_station_idx] agents_position.append((start[0], start[1])) agents_target.append((target[0], target[1]))