From 9432caf9fe1a899259d0b14990b78800c98344c1 Mon Sep 17 00:00:00 2001 From: Erik Nygren <erik.nygren@sbb.ch> Date: Thu, 18 Jul 2019 16:21:55 -0400 Subject: [PATCH] updated agent.moving behavior to give correct value when agent is blocked --- flatland/envs/rail_env.py | 6 ++++-- notebooks/Scene_Editor.ipynb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 4c44afb7..2af0d8b9 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -320,15 +320,17 @@ class RailEnv(Environment): # Perform stored action to transition to the next cell - # Now 'transition_action_on_cellexit' will be guaranteed to be valid; it was checked on entering - # the cell cell_free, new_cell_valid, new_direction, new_position, transition_valid = \ self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent) + # Check that everything is still fee and that the agent can move if all([new_cell_valid, transition_valid, cell_free]): agent.position = new_position agent.direction = new_direction agent.speed_data['position_fraction'] = 0.0 + else: + # If the agent cannot move due to any reason, we set its state to not moving. + agent.moving = False if np.equal(agent.position, agent.target).all(): self.dones[i_agent] = True diff --git a/notebooks/Scene_Editor.ipynb b/notebooks/Scene_Editor.ipynb index 852fddb4..1f653d00 100644 --- a/notebooks/Scene_Editor.ipynb +++ b/notebooks/Scene_Editor.ipynb @@ -70,7 +70,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "5a05a5f0569846dfa58fc6cfc222619a", + "model_id": "68a566e6228d40398ea8432582880311", "version_major": 2, "version_minor": 0 }, -- GitLab