Commit fc7e752c authored by Dipam Chakraborty's avatar Dipam Chakraborty
Browse files

minor refactors

parent e6223ce1
Pipeline #8446 failed with stages
in 6 minutes and 20 seconds
......@@ -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
......
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
......
......@@ -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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment