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

fixed orientation issue

parent 5e1664c8
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,7 @@ env = RailEnv(width=50, ...@@ -37,7 +37,7 @@ env = RailEnv(width=50,
max_tracks_in_city=4, max_tracks_in_city=4,
), ),
schedule_generator=sparse_schedule_generator(), schedule_generator=sparse_schedule_generator(),
number_of_agents=200, number_of_agents=10,
stochastic_data=stochastic_data, # Malfunction data generator stochastic_data=stochastic_data, # Malfunction data generator
obs_builder_object=GlobalObsForRailEnv(), obs_builder_object=GlobalObsForRailEnv(),
remove_agents_at_target=True remove_agents_at_target=True
......
...@@ -74,11 +74,15 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None) -> ...@@ -74,11 +74,15 @@ def sparse_schedule_generator(speed_ratio_map: Mapping[float, float] = None) ->
# Set target for agent # Set target for agent
start_city = agent_start_targets_nodes[agent_idx][0] start_city = agent_start_targets_nodes[agent_idx][0]
target_city = agent_start_targets_nodes[agent_idx][1] target_city = agent_start_targets_nodes[agent_idx][1]
agent_orientation = (agent_start_targets_nodes[agent_idx][2] + np.random.choice([0, 2])) % 4
start_city_idx = np.random.randint(len(train_stations[start_city])) start_city_idx = np.random.randint(len(train_stations[start_city]))
start = train_stations[start_city][start_city_idx] start = train_stations[start_city][start_city_idx]
target_station_idx = np.random.randint(len(train_stations[target_city])) target_station_idx = np.random.randint(len(train_stations[target_city]))
target = train_stations[target_city][target_station_idx] target = train_stations[target_city][target_station_idx]
agent_orientation = (agent_start_targets_nodes[agent_idx][2] + 2 * start[1]) % 4
if not rail.check_path_exists(start[0], agent_orientation, target[0]):
agent_orientation = (agent_orientation + 2) % 4
print(rail.check_path_exists(start[0], agent_orientation, target[0]))
agents_position.append((start[0][0], start[0][1])) agents_position.append((start[0][0], start[0][1]))
agents_target.append((target[0][0], target[0][1])) agents_target.append((target[0][0], target[0][1]))
......
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