diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 413554c6352d74da7ec91a04d170fabb69f51198..3c4a0487da4a543b51841a65411216f5f92acb33 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -400,13 +400,16 @@ class RailEnv(Environment): return True # Restart fixed agents + + if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0: + agent.malfunction_data['next_malfunction'] -= 1 if 'moving_before_malfunction' in agent.malfunction_data: self.agents[i_agent].moving = agent.malfunction_data['moving_before_malfunction'] return False # Break agents that have next_malfunction - if 1 > agent.malfunction_data['malfunction'] and agent.malfunction_data['next_malfunction'] < 1: + if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] < 1: # Increase number of malfunctions agent.malfunction_data['nr_malfunctions'] += 1