From d2351373e6343d24367a98949071070436f6ac13 Mon Sep 17 00:00:00 2001
From: Dipam Chakraborty <dipam@aicrowd.com>
Date: Wed, 27 Oct 2021 12:00:15 +0530
Subject: [PATCH] fix num malfunctions calculation

---
 flatland/envs/step_utils/malfunction_handler.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/flatland/envs/step_utils/malfunction_handler.py b/flatland/envs/step_utils/malfunction_handler.py
index 02976e9d..ef2a4bd6 100644
--- a/flatland/envs/step_utils/malfunction_handler.py
+++ b/flatland/envs/step_utils/malfunction_handler.py
@@ -38,7 +38,8 @@ class MalfunctionHandler:
         # Only set new malfunction value if old malfunction is completed
         if self._malfunction_down_counter == 0:
             self._malfunction_down_counter = val
-            self.num_malfunctions += 1
+            if val > 0:
+                self.num_malfunctions += 1
 
     def generate_malfunction(self, malfunction_generator, np_random):
         num_broken_steps = get_number_of_steps_to_break(malfunction_generator, np_random)
-- 
GitLab