From 085b5a9f7ddd68820df34954187e4fac1b830d7f Mon Sep 17 00:00:00 2001
From: MLErik <baerenjesus@gmail.com>
Date: Sat, 28 Sep 2019 10:23:26 -0400
Subject: [PATCH] minor update to choice of next direction in city connection

---
 examples/flatland_2_0_example.py | 2 +-
 flatland/envs/rail_generators.py | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/examples/flatland_2_0_example.py b/examples/flatland_2_0_example.py
index 7ed5d27c..0099b1cd 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 d1911d4b..f5e377f8 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]:
-- 
GitLab