diff --git a/examples/demo.py b/examples/demo.py index 2ee1d5c0e747b8de11b010ca69d24db465e8f4f1..7e3725bccde4d4635c3a5e5ff275af9606018184 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -164,7 +164,6 @@ class Demo: agent_obs[a] = np.concatenate((time_obs[0][a], time_obs[1][a])) for step in range(max_nbr_of_steps): - self.renderer.renderEnv(show=True) time.sleep(.2) @@ -175,6 +174,8 @@ class Demo: action_prob[action] += 1 action_dict.update({a: action}) + self.renderer.renderEnv(show=True,action_dict=action_dict) + # Environment step next_obs, all_rewards, done, _ = self.env.step(action_dict) for a in range(self.env.get_num_agents()): diff --git a/flatland/utils/render_qt.py b/flatland/utils/render_qt.py index 0f3a0f899e106f71e8a4f14a4bafbb7ed7589efd..73b8ca77a33042bf181097d4b1a0a1afcb48b56e 100644 --- a/flatland/utils/render_qt.py +++ b/flatland/utils/render_qt.py @@ -121,7 +121,7 @@ class QTSVG(GraphicsLayer): self.layout = QGridLayout() self.layout.setSpacing(0) self.wMain.setLayout(self.layout) - self.wWinMain.resize(1000, 1000) + self.wWinMain.resize(600, 600) self.wWinMain.show() self.wWinMain.setFocus() diff --git a/flatland/utils/rendertools.py b/flatland/utils/rendertools.py index 9cc06d1d659236fb88af456b291ec933dbf4de66..713f65f0d726f1b89778982cf0fe1443b4e24282 100644 --- a/flatland/utils/rendertools.py +++ b/flatland/utils/rendertools.py @@ -605,7 +605,7 @@ class RenderTool(object): ) def renderEnv(self, show=False, curves=True, spacing=False, - arrows=False, agents=True, show_observations=True, sRailColor="gray", frames=False, + arrows=False, agents=True, renderobs=True, show_observations=True, sRailColor="gray", frames=False, iEpisode=None, iStep=None, iSelectedAgent=None, action_dict=None): """ @@ -618,9 +618,10 @@ class RenderTool(object): if not self.gl.is_raster(): self.renderEnv2(show, curves, spacing, - arrows, agents, sRailColor, + arrows, agents, renderobs,sRailColor, frames, iEpisode, iStep, iSelectedAgent, action_dict) + return if type(self.gl) in (QTGL, PILGL): @@ -764,13 +765,13 @@ class RenderTool(object): # ** TODO *** # why should we only update if the action is valid ? - if False: + if True: if action_isValid: self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction, color=oColor) else: - pass - # print("invalid action - agent ", iAgent, " bend ", agent.direction, new_direction) - # self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction) + # pass + print("invalid action - agent ", iAgent, " bend ", agent.direction, new_direction) + self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction) else: self.gl.setAgentAt(iAgent, *agent.position, agent.direction, new_direction, color=oColor) diff --git a/flatland/utils/svg.py b/flatland/utils/svg.py index e7c295f7b9d6ecda1b0788e3a6f9af3e02a7051a..fb8b987cae83f4b8a3696e0e9496659045709c17 100644 --- a/flatland/utils/svg.py +++ b/flatland/utils/svg.py @@ -80,6 +80,7 @@ class Zug(object): self.svg_curve2 = SVG("svg/Zug_2_Weiche_#0091ea.svg") def getSvg(self, iAgent, iDirIn, iDirOut, color=None): + delta_dir = (iDirOut - iDirIn) % 4 # if delta_dir != 0: # print("Bend:", iAgent, iDirIn, iDirOut)