Skip to content
Snippets Groups Projects
Commit dfc4ea23 authored by Egli Adrian (IT-SCI-API-PFI)'s avatar Egli Adrian (IT-SCI-API-PFI)
Browse files

bug fix for agent placement (no agents on curves)

parent e1332b10
No related branches found
No related tags found
No related merge requests found
...@@ -896,16 +896,22 @@ def realistic_rail_generator(nr_start_goal=1, seed=0, add_max_dead_end=4, two_tr ...@@ -896,16 +896,22 @@ def realistic_rail_generator(nr_start_goal=1, seed=0, add_max_dead_end=4, two_tr
agents_target = [] agents_target = []
agents_direction = [] agents_direction = []
remove_a = []
for a in range(len(agents_positions)): for a in range(len(agents_positions)):
cell_transitions = grid_map.get_transitions(agents_positions[a][0], agents_positions[a][1], cell_transitions = grid_map.get_transitions(agents_positions[a][0], agents_positions[a][1],
agents_directions[a]) agents_directions[a])
if np.sum(cell_transitions) == 0: if np.sum(cell_transitions) == 0:
agents_directions[a] += 2 for i in range(4):
agents_directions[a] = agents_directions[a] % 4 agents_directions[a] = i
cell_transitions = grid_map.get_transitions(agents_positions[a][0], agents_positions[a][1], cell_transitions = grid_map.get_transitions(agents_positions[a][0], agents_positions[a][1],
agents_directions[a]) agents_directions[a])
if np.sum(cell_transitions) != 0:
break
if np.sum(cell_transitions): if np.sum(cell_transitions):
print(a, "bug") remove_a.extend([a])
for i in range(len(remove_a)):
agents_positions.pop(i)
agents_directions.pop(i)
for a in range(min(len(agents_targets), num_agents)): for a in range(min(len(agents_targets), num_agents)):
t = np.random.choice(range(len(agents_targets))) t = np.random.choice(range(len(agents_targets)))
......
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