Skip to content
Snippets Groups Projects
Commit d4a48e1f authored by Erik Nygren's avatar Erik Nygren :bullettrain_front:
Browse files

Updated step function in envs/rail_env.py

parent 9464e58c
No related branches found
No related tags found
No related merge requests found
......@@ -226,10 +226,11 @@ class RailEnv(Environment):
agent.moving = False
self.rewards_dict[iAgent] += stop_penalty
if not agent.moving and \
(action == RailEnvActions.MOVE_LEFT or
action == RailEnvActions.MOVE_FORWARD or
action == RailEnvActions.MOVE_RIGHT):
if not agent.moving and action == RailEnvActions.MOVE_FORWARD:
# Only allow agent to start moving by pressing forward.
#(action == RailEnvActions.MOVE_LEFT or
# action == RailEnvActions.MOVE_FORWARD or
# action == RailEnvActions.MOVE_RIGHT):
agent.moving = True
self.rewards_dict[iAgent] += start_penalty
......@@ -244,7 +245,7 @@ class RailEnv(Environment):
else:
# Logic: if the chosen action is invalid,
# and it was LEFT or RIGHT, and the agent was moving, then keep moving FORWARD.
if action == RailEnvActions.MOVE_LEFT or action == RailEnvActions.MOVE_RIGHT and agent.moving:
if (action == RailEnvActions.MOVE_LEFT or action == RailEnvActions.MOVE_RIGHT) and agent.moving:
cell_isFree, new_cell_isValid, new_direction, new_position, transition_isValid = \
self._check_action_on_agent(RailEnvActions.MOVE_FORWARD, agent)
......
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