Skip to content
Snippets Groups Projects
Commit 220fc23a authored by mohanty's avatar mohanty
Browse files

Merge branch 'spm/229-tree_obs_iterable_error' into 'master'

Check for existence of position when preparing the lookup tables in treeobs

See merge request flatland/flatland!226
parents a54b37c5 9e64364e
No related branches found
No related tags found
No related merge requests found
......@@ -174,13 +174,15 @@ class TreeObsForRailEnv(ObservationBuilder):
self.location_has_agent_ready_to_depart = {}
for _agent in self.env.agents:
if _agent.status in [RailAgentStatus.ACTIVE, RailAgentStatus.DONE]:
if _agent.status in [RailAgentStatus.ACTIVE, RailAgentStatus.DONE] and \
_agent.position:
self.location_has_agent[tuple(_agent.position)] = 1
self.location_has_agent_direction[tuple(_agent.position)] = _agent.direction
self.location_has_agent_speed[tuple(_agent.position)] = _agent.speed_data['speed']
self.location_has_agent_malfunction[tuple(_agent.position)] = _agent.malfunction_data['malfunction']
if _agent.status in [RailAgentStatus.READY_TO_DEPART]:
if _agent.status in [RailAgentStatus.READY_TO_DEPART] and \
_agent.initial_position:
self.location_has_agent_ready_to_depart[tuple(_agent.initial_position)] = \
self.location_has_agent_ready_to_depart.get(tuple(_agent.initial_position), 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