From c4e002cc4f60df0165bedb13ebdfa9f536ec68bf Mon Sep 17 00:00:00 2001 From: Erik Nygren <erik.nygren@sbb.ch> Date: Tue, 2 Jul 2019 16:39:02 -0400 Subject: [PATCH] fixed rendering bug where position was not updated --- flatland/envs/rail_env.py | 4 ++-- flatland/utils/rendertools.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/flatland/envs/rail_env.py b/flatland/envs/rail_env.py index 0ec2794..26bccf6 100644 --- a/flatland/envs/rail_env.py +++ b/flatland/envs/rail_env.py @@ -195,6 +195,8 @@ class RailEnv(Environment): # for i in range(len(self.agents_handles)): for iAgent in range(self.get_num_agents()): agent = self.agents[iAgent] + agent.old_direction = agent.direction + agent.old_position = agent.position if self.dones[iAgent]: # this agent has already completed... continue @@ -283,8 +285,6 @@ class RailEnv(Environment): self._check_action_on_agent(agent.speed_data['transition_action_on_cellexit'], agent) if all([new_cell_isValid, transition_isValid, cell_isFree]): - agent.old_direction = agent.direction - agent.old_position = agent.position agent.position = new_position agent.direction = new_direction agent.speed_data['position_fraction'] = 0.0 diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 7932aac..537d8be 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -38,7 +38,7 @@ class RenderTool(object): gTheta = np.linspace(0, np.pi / 2, 5) 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.iFrame = 0 self.time1 = time.time() -- GitLab