diff --git a/flatland/envs/observations.py b/flatland/envs/observations.py index 908df4322d58ec13729ce31cb2eebdb8ac0a74c2..5cc3f26d0374cb07a673d05771cbbf64a66f0fc0 100644 --- a/flatland/envs/observations.py +++ b/flatland/envs/observations.py @@ -266,7 +266,6 @@ class TreeObsForRailEnv(ObservationBuilder): other_agent_same_direction = 0 other_agent_opposite_direction = 0 - num_steps = 1 while exploring: # ############################# @@ -378,7 +377,6 @@ class TreeObsForRailEnv(ObservationBuilder): ] """ - if last_isTarget: observation = [0, other_target_encountered, diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index c8551b6ec4c18d5e15bb42ff9a0eef1dc1e791e9..8cd482c08bea3f72630fed3ea97c59583cbd304c 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -215,21 +215,14 @@ class RailEnv(Environment): if action == RailEnvActions.DO_NOTHING and agent.moving: # Keep moving - # Changed MOVE_FORWARD to DO_NOTHING - # action_dict[iAgent] = RailEnvActions.DO_NOTHING action = RailEnvActions.MOVE_FORWARD if action == RailEnvActions.STOP_MOVING and agent.moving: - # action_dict[iAgent] = RailEnvActions.DO_NOTHING - # CHanged DO_NOTHING to STOP_MOVING - # action = RailEnvActions.STOP_MOVING 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. agent.moving = True self.rewards_dict[iAgent] += start_penalty @@ -244,7 +237,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)