From 0d09232d7baa247ebf87c5ab48ba6bf472422101 Mon Sep 17 00:00:00 2001 From: Dipam Chakraborty <dipam@aicrowd.com> Date: Tue, 26 Oct 2021 18:20:34 +0530 Subject: [PATCH] bugfix for malfunction off map to stopped on action do nothing --- flatland/envs/rail_env.py | 6 +++--- flatland/envs/step_utils/action_preprocessing.py | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 8c8bf24f..1a064c99 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -540,8 +540,8 @@ class RailEnv(Environment): new_position, new_direction = agent.position, agent.direction # Add agent to the map if not on it yet elif agent.position is None and agent.action_saver.is_action_saved: - new_position = agent.initial_position - new_direction = agent.initial_direction + new_position = agent.initial_position + new_direction = agent.initial_direction # If movement is allowed apply saved action independent of other agents elif agent.action_saver.is_action_saved and position_update_allowed: saved_action = agent.action_saver.saved_action @@ -553,7 +553,7 @@ class RailEnv(Environment): preprocessed_action = saved_action else: new_position, new_direction = agent.position, agent.direction - + temp_transition_data[i_agent] = env_utils.AgentTransitionData(position=new_position, direction=new_direction, preprocessed_action=preprocessed_action) diff --git a/flatland/envs/step_utils/action_preprocessing.py b/flatland/envs/step_utils/action_preprocessing.py index 47f06e2c..45a81a1a 100644 --- a/flatland/envs/step_utils/action_preprocessing.py +++ b/flatland/envs/step_utils/action_preprocessing.py @@ -17,7 +17,7 @@ def process_do_nothing(state: TrainState, saved_action: RailEnvActions): elif saved_action: action = saved_action else: - action = RailEnvActions.STOP_MOVING + action = RailEnvActions.DO_NOTHING return action @@ -40,7 +40,6 @@ def preprocess_raw_action(action, state, saved_action): """ Preprocesses actions to handle different situations of usage of action based on context - DO_NOTHING is converted to FORWARD if train is moving - - DO_NOTHING is converted to STOP_MOVING if train is moving """ action = process_illegal_action(action) -- GitLab