From e00afaf5874a0cf1eea462cfc45ec3b96cbeca43 Mon Sep 17 00:00:00 2001
From: MLErik <baerenjesus@gmail.com>
Date: Mon, 28 Oct 2019 15:33:58 -0400
Subject: [PATCH] this adresses #263:

refactoring of the fixing agent code part
---
 flatland/envs/rail_env.py | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py
index 8eb6aede..f8534640 100644
--- a/flatland/envs/rail_env.py
+++ b/flatland/envs/rail_env.py
@@ -399,18 +399,18 @@ class RailEnv(Environment):
             agent.malfunction_data['malfunction'] -= 1
             return True
 
-        # Restart fixed agents
-        if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0 and not agent.malfunction_data['fixed']:
-            agent.malfunction_data['next_malfunction'] -= 1
-            agent.malfunction_data['fixed'] = True
-            if 'moving_before_malfunction' in agent.malfunction_data:
-                self.agents[i_agent].moving = agent.malfunction_data['moving_before_malfunction']
-            return False
-
-        # Agent has been running smoothly
-        elif agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0:
-            agent.malfunction_data['next_malfunction'] -= 1
-            return False
+        if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] > 0:
+            # Restart fixed agents
+            if not agent.malfunction_data['fixed']:
+                agent.malfunction_data['next_malfunction'] -= 1
+                agent.malfunction_data['fixed'] = True
+                if 'moving_before_malfunction' in agent.malfunction_data:
+                    self.agents[i_agent].moving = agent.malfunction_data['moving_before_malfunction']
+                return False
+            else:
+                # Agent has been running smoothly
+                agent.malfunction_data['next_malfunction'] -= 1
+                return False
 
         # Break agents that have next_malfunction
         if agent.malfunction_data['malfunction'] < 1 and agent.malfunction_data['next_malfunction'] < 1:
-- 
GitLab