From fc7e752ca101bc46cec61907f610ed744f4cbac3 Mon Sep 17 00:00:00 2001
From: Dipam Chakraborty <dipam@aicrowd.com>
Date: Thu, 9 Sep 2021 20:41:36 +0530
Subject: [PATCH] minor refactors

---
 flatland/envs/agent_chains.py | 8 ++++----
 flatland/envs/agent_utils.py  | 6 +-----
 flatland/envs/rail_env.py     | 6 +++---
 3 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/flatland/envs/agent_chains.py b/flatland/envs/agent_chains.py
index 3e566ad0..e99b1dae 100644
--- a/flatland/envs/agent_chains.py
+++ b/flatland/envs/agent_chains.py
@@ -218,21 +218,21 @@ class MotionCheck(object):
         if "color" in dAttr:
             sColor = dAttr["color"]
             if sColor in [ "red", "purple" ]:
-                return (False, rcPos)
+                return False
 
         dSucc = self.G.succ[rcPos]
 
         # This should never happen - only the next cell of an agent has no successor
         if len(dSucc)==0:
             print(f"error condition - agent {iAgent} node {rcPos} has no successor")
-            return (False, rcPos)
+            return False
 
         # This agent has a successor
         rcNext = self.G.successors(rcPos).__next__()
         if rcNext == rcPos:  # the agent didn't want to move
-            return (False, rcNext)
+            return False
         # The agent wanted to move, and it can
-        return (True, rcNext)
+        return True
 
 
 
diff --git a/flatland/envs/agent_utils.py b/flatland/envs/agent_utils.py
index bf926371..23f8c032 100644
--- a/flatland/envs/agent_utils.py
+++ b/flatland/envs/agent_utils.py
@@ -1,8 +1,4 @@
-from flatland.envs.rail_trainrun_data_structures import Waypoint
-import numpy as np
-
-from itertools import starmap
-from typing import Tuple, Optional, NamedTuple, List
+from typing import Tuple, Optional, NamedTuple
 
 from attr import attr, attrs, attrib, Factory
 
diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py
index c8f75908..75b10e8f 100644
--- a/flatland/envs/rail_env.py
+++ b/flatland/envs/rail_env.py
@@ -549,7 +549,7 @@ class RailEnv(Environment):
             if agent.malfunction_handler.in_malfunction:
                 movement_allowed = False
             else:
-                movement_allowed, _ = self.motionCheck.check_motion(i_agent, agent.position) # TODO: Remove final_new_postion from motioncheck
+                movement_allowed = self.motionCheck.check_motion(i_agent, agent.position) # TODO: Remove final_new_postion from motioncheck
 
             if movement_allowed:
                 agent.position = agent_transition_data.position
@@ -567,7 +567,7 @@ class RailEnv(Environment):
                 agent.position = None
 
             ## Update rewards
-            # self.update_rewards(i_agent, agent, rail)
+            # self.update_rewards(i_agent, agent, rail) # TODO : Rewards - Fix this
 
             ## Update counters (malfunction and speed)
             agent.speed_counter.update_counter(agent.state)
@@ -577,7 +577,7 @@ class RailEnv(Environment):
             if agent.speed_counter.is_cell_entry:
                 agent.action_saver.clear_saved_action()
         
-        self.rewards_dict = {i_agent: 0 for i_agent in range(len(self.agents))} # TODO : Remove this
+        self.rewards_dict = {i_agent: 0 for i_agent in range(len(self.agents))} # TODO : Rewards - Remove this
         return self._get_observations(), self.rewards_dict, self.dones, info_dict # TODO : Will need changes?
 
     def record_timestep(self, dActions):
-- 
GitLab