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

updated observation to cummulate the number of observed agents with same or...

updated observation to cummulate the number of observed agents with same or other direction along each branch
parent 735c8624
No related branches found
No related tags found
No related merge requests found
......@@ -263,6 +263,9 @@ class TreeObsForRailEnv(ObservationBuilder):
other_agent_encountered = np.inf
other_target_encountered = np.inf
other_agent_same_direction = 0
other_agent_opposite_direction = 0
num_steps = 1
while exploring:
......@@ -274,6 +277,14 @@ class TreeObsForRailEnv(ObservationBuilder):
if num_steps < other_agent_encountered:
other_agent_encountered = num_steps
if self.location_has_agent_direction[position] == direction:
# Cummulate the number of agents on branch with same direction
other_agent_same_direction += 1
if self.location_has_agent_direction[position] != direction:
# Cummulate the number of agents on branch with other direction
other_agent_opposite_direction += 1
if position in self.location_has_target:
if num_steps < other_target_encountered:
other_target_encountered = num_steps
......@@ -366,10 +377,7 @@ class TreeObsForRailEnv(ObservationBuilder):
other_agent_opposite_direction
]
"""
other_agent_same_direction = \
1 if position in self.location_has_agent and self.location_has_agent_direction[position] == direction else 0
other_agent_opposite_direction = \
1 if position in self.location_has_agent and self.location_has_agent_direction[position] != direction else 0
if last_isTarget:
observation = [0,
......
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