Skip to content
Snippets Groups Projects
Commit 0d09232d authored by Dipam Chakraborty's avatar Dipam Chakraborty
Browse files

bugfix for malfunction off map to stopped on action do nothing

parent 5f5c34d6
No related branches found
No related tags found
No related merge requests found
...@@ -540,8 +540,8 @@ class RailEnv(Environment): ...@@ -540,8 +540,8 @@ class RailEnv(Environment):
new_position, new_direction = agent.position, agent.direction new_position, new_direction = agent.position, agent.direction
# Add agent to the map if not on it yet # Add agent to the map if not on it yet
elif agent.position is None and agent.action_saver.is_action_saved: elif agent.position is None and agent.action_saver.is_action_saved:
new_position = agent.initial_position new_position = agent.initial_position
new_direction = agent.initial_direction new_direction = agent.initial_direction
# If movement is allowed apply saved action independent of other agents # If movement is allowed apply saved action independent of other agents
elif agent.action_saver.is_action_saved and position_update_allowed: elif agent.action_saver.is_action_saved and position_update_allowed:
saved_action = agent.action_saver.saved_action saved_action = agent.action_saver.saved_action
...@@ -553,7 +553,7 @@ class RailEnv(Environment): ...@@ -553,7 +553,7 @@ class RailEnv(Environment):
preprocessed_action = saved_action preprocessed_action = saved_action
else: else:
new_position, new_direction = agent.position, agent.direction new_position, new_direction = agent.position, agent.direction
temp_transition_data[i_agent] = env_utils.AgentTransitionData(position=new_position, temp_transition_data[i_agent] = env_utils.AgentTransitionData(position=new_position,
direction=new_direction, direction=new_direction,
preprocessed_action=preprocessed_action) preprocessed_action=preprocessed_action)
......
...@@ -17,7 +17,7 @@ def process_do_nothing(state: TrainState, saved_action: RailEnvActions): ...@@ -17,7 +17,7 @@ def process_do_nothing(state: TrainState, saved_action: RailEnvActions):
elif saved_action: elif saved_action:
action = saved_action action = saved_action
else: else:
action = RailEnvActions.STOP_MOVING action = RailEnvActions.DO_NOTHING
return action return action
...@@ -40,7 +40,6 @@ def preprocess_raw_action(action, state, saved_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 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 FORWARD if train is moving
- DO_NOTHING is converted to STOP_MOVING if train is moving
""" """
action = process_illegal_action(action) action = process_illegal_action(action)
......
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