diff --git a/examples/flatland_2_0_example.py b/examples/flatland_2_0_example.py index 6396f4123adf895c381c2a21f6d8dc6e4e823b92..57e99ffb89e9f6584fff9707de921c5fda101585 100644 --- a/examples/flatland_2_0_example.py +++ b/examples/flatland_2_0_example.py @@ -32,8 +32,8 @@ speed_ration_map = {1.: 0.25, # Fast passenger train env = RailEnv(width=50, height=50, - rail_generator=sparse_rail_generator(num_cities=10, # Number of cities in map (where train stations are) - seed=1, # Random seed + rail_generator=sparse_rail_generator(num_cities=50, # Number of cities in map (where train stations are) + seed=0, # Random seed grid_mode=False, max_inter_city_rails=2, max_tracks_in_city=4, diff --git a/flatland/envs/rail_generators.py b/flatland/envs/rail_generators.py index 6cfbece9a3203772e05ddb08dff51575f4f012d4..cc516de2174d262fdc5c5086b01921c183323031 100644 --- a/flatland/envs/rail_generators.py +++ b/flatland/envs/rail_generators.py @@ -632,7 +632,7 @@ def sparse_rail_generator(num_cities=5, grid_mode=False, max_inter_city_rails=4, to_close = False # Check distance to nodes for node_pos in node_positions: - if _city_overlap((x_tmp, y_tmp), node_pos, 2 * node_radius + 2): + if _city_overlap((x_tmp, y_tmp), node_pos, 2 * (node_radius + 1) + 1): to_close = True if not to_close: @@ -801,7 +801,7 @@ def sparse_rail_generator(num_cities=5, grid_mode=False, max_inter_city_rails=4, if track_id % 2 == 0: source = inner_connection_points[current_city][boarder][track_id] target = inner_connection_points[current_city][opposite_boarder][track_id] - current_track = connect_straigt_line(rail_trans, grid_map, source, target) + current_track = connect_straigt_line(rail_trans, grid_map, source, target, False) if target in all_outer_connection_points and source in \ all_outer_connection_points and len(through_path_cells[current_city]) < 1: through_path_cells[current_city].extend(current_track) @@ -809,7 +809,7 @@ def sparse_rail_generator(num_cities=5, grid_mode=False, max_inter_city_rails=4, source = inner_connection_points[current_city][opposite_boarder][track_id] target = inner_connection_points[current_city][boarder][track_id] - current_track = connect_straigt_line(rail_trans, grid_map, source, target) + current_track = connect_straigt_line(rail_trans, grid_map, source, target, False) if target in all_outer_connection_points and source in \ all_outer_connection_points and len(through_path_cells[current_city]) < 1: through_path_cells[current_city].extend(current_track)