Commit c4e002cc authored by Erik Nygren's avatar Erik Nygren
Browse files

fixed rendering bug where position was not updated

parent 1a3fc65e
Pipeline #1290 passed with stages
in 9 minutes and 35 seconds
...@@ -195,6 +195,8 @@ class RailEnv(Environment): ...@@ -195,6 +195,8 @@ class RailEnv(Environment):
# for i in range(len(self.agents_handles)): # for i in range(len(self.agents_handles)):
for iAgent in range(self.get_num_agents()): for iAgent in range(self.get_num_agents()):
agent = self.agents[iAgent] agent = self.agents[iAgent]
agent.old_direction = agent.direction
agent.old_position = agent.position
if self.dones[iAgent]: # this agent has already completed... if self.dones[iAgent]: # this agent has already completed...
continue continue
...@@ -283,8 +285,6 @@ class RailEnv(Environment): ...@@ -283,8 +285,6 @@ class RailEnv(Environment):
self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent) self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent)
if all([new_cell_isValid, transition_isValid, cell_isFree]): if all([new_cell_isValid, transition_isValid, cell_isFree]):
agent.old_direction = agent.direction
agent.old_position = agent.position
agent.position = new_position agent.position = new_position
agent.direction = new_direction agent.direction = new_direction
agent.speed_data['position_fraction'] = 0.0 agent.speed_data['position_fraction'] = 0.0
......
...@@ -38,7 +38,7 @@ class RenderTool(object): ...@@ -38,7 +38,7 @@ class RenderTool(object):
gTheta = np.linspace(0, np.pi / 2, 5) gTheta = np.linspace(0, np.pi / 2, 5)
gArc = array([np.cos(gTheta), np.sin(gTheta)]).T # from [1,0] to [0,1] gArc = array([np.cos(gTheta), np.sin(gTheta)]).T # from [1,0] to [0,1]
def __init__(self, env, gl="PILSVG", jupyter=False, agentRenderVariant=AgentRenderVariant.AGENT_SHOWS_OPTIONS): def __init__(self, env, gl="PILSVG", jupyter=False, agentRenderVariant=AgentRenderVariant.ONE_STEP_BEHIND):
self.env = env self.env = env
self.iFrame = 0 self.iFrame = 0
self.time1 = time.time() self.time1 = time.time()
......
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