diff --git a/examples/simple_example_3.py b/examples/simple_example_3.py index e015b3c88cf05a8d047f15dfaf88e8a2fd9ce789..1661ef65a9a33f3b44a098caaf83317919722398 100644 --- a/examples/simple_example_3.py +++ b/examples/simple_example_3.py @@ -2,7 +2,7 @@ import random import numpy as np -from flatland.envs.generators import random_rail_generator, complex_rail_generator +from flatland.envs.generators import random_rail_generator from flatland.envs.observations import TreeObsForRailEnv from flatland.envs.rail_env import RailEnv from flatland.utils.rendertools import RenderTool diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index 45733defbf19227ed90bfafb5cee0abf90e36c4e..c7cb8fa12ea2a18974d3d968c8f04128d0daf624 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -75,6 +75,7 @@ class PILGL(GraphicsLayer): self.ltAgentColors = [self.rgb_s2i(sColor) for sColor in sColors.split("#")] self.nAgentColors = len(self.ltAgentColors) + self.window_root = None self.window_open = False self.firstFrame = True self.create_layers() @@ -131,7 +132,9 @@ class PILGL(GraphicsLayer): assert self.window_open is False, "Window is already open!" # use tk.Toplevel() instead of tk.Tk() # https://stackoverflow.com/questions/26097811/image-pyimage2-doesnt-exist - self.window = tk.Toplevel() + self.window_root = tk.Tk() + self.window_root.withdraw() + self.window = tk.Toplevel(self.window_root) self.window.title("Flatland") self.window.configure(background='grey') self.window_open = True @@ -140,6 +143,8 @@ class PILGL(GraphicsLayer): self.panel.destroy() self.window.quit() self.window.destroy() + self.window_root.destroy() + self.window = None def text(self, *args, **kwargs): pass diff --git a/tests/test_environments.py b/tests/test_environments.py index aa24467dd1d548a2b68a408f300089ee8135c639..79160ce549155ea7dc8e905f015642d7b6ed5723 100644 --- a/tests/test_environments.py +++ b/tests/test_environments.py @@ -107,7 +107,6 @@ def test_rail_environment_single_agent(): if prev_pos != pos: valid_active_actions_done += 1 - # After 6 movements on this railway network, the train should be back # to its original height on the map. assert (initial_pos[0] == agent.position[0]) @@ -124,8 +123,10 @@ def test_rail_environment_single_agent(): _, _, dones, _ = rail_env.step({0: action}) done = dones['__all__'] + test_rail_environment_single_agent() + def test_dead_end(): transitions = Grid4Transitions([])