Skip to content
Snippets Groups Projects
Commit 9432caf9 authored by Erik Nygren's avatar Erik Nygren
Browse files

updated agent.moving behavior to give correct value when agent is blocked

parent 77a5f1e9
No related branches found
No related tags found
No related merge requests found
...@@ -320,15 +320,17 @@ class RailEnv(Environment): ...@@ -320,15 +320,17 @@ class RailEnv(Environment):
# Perform stored action to transition to the next cell # 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 = \ cell_free, new_cell_valid, new_direction, new_position, transition_valid = \
self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent) 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]): if all([new_cell_valid, transition_valid, cell_free]):
agent.position = new_position agent.position = new_position
agent.direction = new_direction agent.direction = new_direction
agent.speed_data['position_fraction'] = 0.0 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(): if np.equal(agent.position, agent.target).all():
self.dones[i_agent] = True self.dones[i_agent] = True
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
{ {
"data": { "data": {
"application/vnd.jupyter.widget-view+json": { "application/vnd.jupyter.widget-view+json": {
"model_id": "5a05a5f0569846dfa58fc6cfc222619a", "model_id": "68a566e6228d40398ea8432582880311",
"version_major": 2, "version_major": 2,
"version_minor": 0 "version_minor": 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