From b669de03cb7fe180861062c7072daedf4b853228 Mon Sep 17 00:00:00 2001 From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch> Date: Mon, 17 Jun 2019 18:15:55 +0200 Subject: [PATCH] Editor add agent and move target error fixed --- examples/demo.py | 3 ++- flatland/utils/editor.py | 2 ++ notebooks/Scene_Editor.ipynb | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/demo.py b/examples/demo.py index fa89771..ae19ced 100644 --- a/examples/demo.py +++ b/examples/demo.py @@ -96,6 +96,7 @@ class Demo: for iAgent in range(self.env.get_num_agents()): # allways walk straight forward action = 2 + action = np.random.choice([0, 1, 2, 3], 1, p=[0.0, 0.5, 0.5, 0.0])[0] # update the actions action_dict.update({iAgent: action}) @@ -161,7 +162,7 @@ class Demo: @staticmethod def run_complex_scene(): - demo_001 = Demo(Scenario_Generator.load_scenario('complex_scene.pkl')) + demo_001 = Demo(Scenario_Generator.load_scenario('demo_001.pkl')) demo_001.set_record_frames(os.path.join(__file_dirname__, '..', 'rendering', 'frame_{:04d}.bmp')) demo_001.run_demo(120) diff --git a/flatland/utils/editor.py b/flatland/utils/editor.py index 081cf02..d385f41 100644 --- a/flatland/utils/editor.py +++ b/flatland/utils/editor.py @@ -722,6 +722,7 @@ class EditorModel(object): agent_static = EnvAgentStatic(rcCell, 0, rcCell, moving=False) self.iSelectedAgent = self.env.add_agent_static(agent_static) self.player = None # will need to start a new player + self.view.oRT.update_background() else: # Move the selected agent to this cell agent_static = self.env.agents_static[self.iSelectedAgent] @@ -745,6 +746,7 @@ class EditorModel(object): if self.iSelectedAgent is not None: self.env.agents_static[self.iSelectedAgent].target = rcCell self.init_agents_static = None + self.view.oRT.update_background() self.redraw() def step(self): diff --git a/notebooks/Scene_Editor.ipynb b/notebooks/Scene_Editor.ipynb index 444c1eb..18b18a1 100644 --- a/notebooks/Scene_Editor.ipynb +++ b/notebooks/Scene_Editor.ipynb @@ -100,7 +100,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "140f16d2c9a643e39d68c6421e50b9bd", + "model_id": "485775e396784212ae3b33c820f3ec25", "version_major": 2, "version_minor": 0 }, -- GitLab