From 43d9ef66d0b6499b07c12c62f5b53796eb4708f8 Mon Sep 17 00:00:00 2001 From: MLErik <baerenjesus@gmail.com> Date: Sun, 18 Aug 2019 08:52:30 -0400 Subject: [PATCH] decrease optical size of levels @adrian please fix visuals.. ,) --- flatland/envs/generators.py | 1 + flatland/utils/graphics_pil.py | 10 +++++----- tests/test_flatland_env_sparse_rail_generator.py | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/flatland/envs/generators.py b/flatland/envs/generators.py index 4463b1e3..0c1b7d15 100644 --- a/flatland/envs/generators.py +++ b/flatland/envs/generators.py @@ -842,6 +842,7 @@ def sparse_rail_generator(num_cities=100, num_intersections=10, num_trainstation node_positions = [] city_positions = [] intersection_positions = [] + for node_idx in range(num_cities + num_intersections): to_close = True tries = 0 diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index f86f301c..d8dbbfff 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -52,10 +52,10 @@ class PILGL(GraphicsLayer): self.background_grid = np.zeros(shape=(self.width, self.height)) if jupyter is False: - # NOTE: Currently removed the dependency on - # screeninfo. We have to find an alternate + # NOTE: Currently removed the dependency on + # screeninfo. We have to find an alternate # way to compute the screen width and height - # In the meantime, we are harcoding the 800x600 + # In the meantime, we are harcoding the 800x600 # assumption self.screen_width = 800 self.screen_height = 600 @@ -114,7 +114,7 @@ class PILGL(GraphicsLayer): for rc in dTargets: r = rc[1] c = rc[0] - d = int(np.floor(np.sqrt((x - r) ** 2 + (y - c) ** 2))) + d = int(np.floor(np.sqrt((x - r) ** 2 + (y - c) ** 2)) / 0.5) distance = min(d, distance) self.background_grid[x][y] = distance @@ -444,7 +444,7 @@ class PILSVG(PILGL): for transition, file in file_directory.items(): - # Translate the ascii transition description in the format "NE WS" to the + # Translate the ascii transition description in the format "NE WS" to the # binary list of transitions as per RailEnv - NESW (in) x NESW (out) transition_16_bit = ["0"] * 16 for sTran in transition.split(" "): diff --git a/tests/test_flatland_env_sparse_rail_generator.py b/tests/test_flatland_env_sparse_rail_generator.py index f49893ae..1b274bca 100644 --- a/tests/test_flatland_env_sparse_rail_generator.py +++ b/tests/test_flatland_env_sparse_rail_generator.py @@ -25,15 +25,15 @@ def test_realistic_rail_generator(): def test_sparse_rail_generator(): env = RailEnv(width=50, height=50, - rail_generator=sparse_rail_generator(num_cities=2, # Number of cities in map - num_intersections=3, # Number of interesections in map - num_trainstations=5, # Number of possible start/targets on map - min_node_dist=10, # Minimal distance of nodes - node_radius=2, # Proximity of stations to city center - num_neighb=3, # Number of connections to other cities + rail_generator=sparse_rail_generator(num_cities=3, # Number of cities in map + num_intersections=2, # Number of interesections in map + num_trainstations=15, # Number of possible start/targets on map + min_node_dist=6, # Minimal distance of nodes + node_radius=3, # Proximity of stations to city center + num_neighb=2, # Number of connections to other cities seed=5, # Random seed ), - number_of_agents=0, + number_of_agents=10, obs_builder_object=GlobalObsForRailEnv()) # reset to initialize agents_static env_renderer = RenderTool(env, gl="PILSVG", ) -- GitLab