Agent counts itself as ``other_agent_encountered`` in dead end
Hello,
In the following example:
the train has the following observation:
Node(dist_own_target_encountered=0, dist_other_target_encountered=0, dist_other_agent_encountered=0,
dist_potential_conflict=0, dist_unusable_switch=0, dist_to_next_branch=0, dist_min_to_target=5.0,
num_agents_same_direction=0, num_agents_opposite_direction=0, num_agents_malfunctioning=0, speed_min_fractional=1.0,
num_agents_ready_to_depart=0, position=(1, 1), childs={'L': -inf, 'F': Node(dist_own_target_encountered=inf,
dist_other_target_encountered=inf, dist_other_agent_encountered=inf, dist_potential_conflict=inf, dist_unusable_switch=inf, dist_to_next_branch=1, dist_min_to_target=4.0, num_agents_same_direction=0,
num_agents_opposite_direction=0, num_agents_malfunctioning=0, speed_min_fractional=1.0,
num_agents_ready_to_depart=0, position=(1, 0), childs={'L': -inf, 'F': Node(dist_own_target_encountered=5,
dist_other_target_encountered=inf, **dist_other_agent_encountered=2**, dist_potential_conflict=inf,
dist_unusable_switch=inf, dist_to_next_branch=5, dist_min_to_target=0, num_agents_same_direction=0,
num_agents_opposite_direction=1, num_agents_malfunctioning=0, speed_min_fractional=1.0,
num_agents_ready_to_depart=0, position=(1, 4), childs={'L': -inf, 'F': -inf, 'R': -inf, 'B': -inf}), 'R': -inf, 'B': -inf}), 'R': -inf, 'B': -inf})
As you can see, the agent does not distinguish itself from other agents that is why we have dist_other_agent_encountered=2
.
In the TreeObsForRailEnv._explore_branch
method the following code is responsible for saving the distance to other encountered agents:
if position in self.location_has_agent:
if tot_dist < other_agent_encountered:
other_agent_encountered = tot_dist
So I think it would be better if self.location_has_agent
stores the id
of the agent if it is occupied and check if it is the same as the handle
passed to the TreeObsForRailEnv.get
method.
Thank you in advance,