From 543a88d9674617ae4c4cbc647dbb7c5e96981033 Mon Sep 17 00:00:00 2001 From: MLErik <baerenjesus@gmail.com> Date: Sat, 17 Aug 2019 16:52:26 -0400 Subject: [PATCH] fixed bug where agents started on top of each other --- flatland/envs/generators.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flatland/envs/generators.py b/flatland/envs/generators.py index 50759734..0b7ea708 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])) -- GitLab