From 0b18e5edefb8ffd171b1bc3f3d7c8e14a9a503b5 Mon Sep 17 00:00:00 2001 From: MLErik <baerenjesus@gmail.com> Date: Mon, 28 Oct 2019 16:35:55 -0400 Subject: [PATCH] this adresses isse #264. Fixed how we handle agents off the grid with the observation example --- ...custom_observation_example_02_SingleAgentNavigationObs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/custom_observation_example_02_SingleAgentNavigationObs.py b/examples/custom_observation_example_02_SingleAgentNavigationObs.py index aa9da849..1403ac7a 100644 --- a/examples/custom_observation_example_02_SingleAgentNavigationObs.py +++ b/examples/custom_observation_example_02_SingleAgentNavigationObs.py @@ -34,8 +34,11 @@ class SingleAgentNavigationObs(ObservationBuilder): def get(self, handle: int = 0) -> List[int]: agent = self.env.agents[handle] + if agent.position: + possible_transitions = self.env.rail.get_transitions(*agent.position, agent.direction) + else: + possible_transitions = self.env.rail.get_transitions(*agent.initial_position, agent.direction) - possible_transitions = self.env.rail.get_transitions(*agent.position, agent.direction) num_transitions = np.count_nonzero(possible_transitions) # Start from the current orientation, and see which transitions are available; -- GitLab