diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index d5f414913f849094891b2d0dd06c7ca7789f2969..32135f110bd2258df74aa6f91e32dc5043516b58 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -407,13 +407,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