Skip to content
Snippets Groups Projects
Commit 1d8a6479 authored by Erik Nygren's avatar Erik Nygren :bullettrain_front:
Browse files

updated city connection to avoid city centers

parent 5d8b904c
No related branches found
No related tags found
No related merge requests found
...@@ -34,10 +34,10 @@ env = RailEnv(width=50, ...@@ -34,10 +34,10 @@ env = RailEnv(width=50,
height=50, height=50,
rail_generator=sparse_rail_generator(num_cities=9, # Number of cities in map (where train stations are) rail_generator=sparse_rail_generator(num_cities=9, # Number of cities in map (where train stations are)
num_trainstations=50, # Number of possible start/targets on map num_trainstations=50, # Number of possible start/targets on map
min_node_dist=8, # Minimal distance of nodes min_node_dist=5, # Minimal distance of nodes
node_radius=3, # Proximity of stations to city center node_radius=3, # Proximity of stations to city center
seed=15, # Random seed seed=15, # Random seed
grid_mode=False, grid_mode=True,
max_connection_points_per_side=2, max_connection_points_per_side=2,
max_nr_connection_directions=4 max_nr_connection_directions=4
), ),
......
...@@ -98,10 +98,11 @@ def a_star(grid_map: GridTransitionMap, ...@@ -98,10 +98,11 @@ def a_star(grid_map: GridTransitionMap,
# create new node # create new node
new_node = AStarNode(node_pos, current_node) new_node = AStarNode(node_pos, current_node)
# Skip paths through forbidden regions. # Skip paths through forbidden regions if they are provided
if forbidden_cells is not None: if forbidden_cells is not None:
if node_pos in forbidden_cells and new_node != start_node and new_node != end_node: if node_pos in forbidden_cells and new_node != start_node and new_node != end_node:
continue continue
children.append(new_node) children.append(new_node)
# loop through children # loop through children
......
...@@ -576,7 +576,6 @@ def sparse_rail_generator(num_cities=5, num_trainstations=2, min_node_dist=20, n ...@@ -576,7 +576,6 @@ def sparse_rail_generator(num_cities=5, num_trainstations=2, min_node_dist=20, n
node_positions, city_cells = _generate_node_positions_grid_mode(nb_nodes, height, width) node_positions, city_cells = _generate_node_positions_grid_mode(nb_nodes, height, width)
else: else:
node_positions, city_cells = _generate_node_positions_not_grid_mode(nb_nodes, height, width) node_positions, city_cells = _generate_node_positions_not_grid_mode(nb_nodes, height, width)
print(city_cells)
# reduce nb_nodes, _num_cities, _num_intersections if less were generated in not_grid_mode # reduce nb_nodes, _num_cities, _num_intersections if less were generated in not_grid_mode
nb_nodes = len(node_positions) nb_nodes = len(node_positions)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment