diff --git a/examples/demo.py b/examples/demo.py index 06f8f5bd6ff998359a633682d43dba2076545eec..25e9b8cbf52c45d4afa9cc76b5456ec211fb8f73 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -101,11 +101,12 @@ class Demo: # update the actions action_dict.update({iAgent: action}) + # render + self.renderer.renderEnv(show=True, show_observations=False) + # environment step (apply the actions to all agents) next_obs, all_rewards, done, _ = self.env.step(action_dict) - # render - self.renderer.renderEnv(show=True, show_observations=False) if done['__all__']: break diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 759b55a92f46bf1503c85d9c74667537b072e6b2..b4edd99c6157c39377e4d2dfa3612f2aef295838 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -673,15 +673,9 @@ class RenderTool(object): direction = agent.direction old_direction = agent.direction - if agent.position[0] == agent.target[0] and agent.position[1] == agent.target[1]: - # setAgentAt uses the agent index for the color - self.gl.setCellOccupied(iAgent, *(agent.position)) - self.gl.setCellOccupied(iAgent, *(agent.old_position)) - else: - # setAgentAt uses the agent index for the color - self.gl.setCellOccupied(iAgent, *(agent.position)) - position = agent.position - self.gl.setAgentAt(iAgent, *position, old_direction, direction, iSelectedAgent == iAgent) + # setAgentAt uses the agent index for the color + self.gl.setCellOccupied(iAgent, *(agent.position)) + self.gl.setAgentAt(iAgent, *position, old_direction, direction, iSelectedAgent == iAgent) if show_observations: self.renderObs(range(env.get_num_agents()), env.dev_obs_dict)