From cf66525cadbf3ebdd1fb619b4fb6276996c3b216 Mon Sep 17 00:00:00 2001 From: "Egli Adrian (IT-SCI-API-PFI)" <adrian.egli@sbb.ch> Date: Wed, 25 Sep 2019 07:28:05 +0200 Subject: [PATCH] cleanup rendering --- flatland/envs/rail_env_utils.py | 10 +++++----- flatland/utils/graphics_pil.py | 2 -- tests/test_flatland_envs_predictions.py | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/flatland/envs/rail_env_utils.py b/flatland/envs/rail_env_utils.py index b23347da..13781f12 100644 --- a/flatland/envs/rail_env_utils.py +++ b/flatland/envs/rail_env_utils.py @@ -110,9 +110,9 @@ def get_shortest_paths(distance_map: DistanceMap) -> Dict[int, List[ShortestPath position = best_next_action.next_position direction = best_next_action.next_direction - if position == a.target: - shortest_paths[a.handle].append( - ShortestPathElement(position, direction, - RailEnvNextAction(RailEnvActions.DO_NOTHING, position, direction))) - return shortest_paths + shortest_paths[a.handle].append( + ShortestPathElement(position, direction, + RailEnvNextAction(RailEnvActions.STOP_MOVING, position, direction))) + + return shortest_paths diff --git a/flatland/utils/graphics_pil.py b/flatland/utils/graphics_pil.py index 92a0f84f..4dad2ca8 100644 --- a/flatland/utils/graphics_pil.py +++ b/flatland/utils/graphics_pil.py @@ -174,7 +174,6 @@ class PILGL(GraphicsLayer): self.draws[layer].text(xyPixLeftTop, strText, font=self.font, fill=(0, 0, 0, 255)) def text_rowcol(self, rcTopLeft, strText, layer=AGENT_LAYER): - print("Text:", "rc:", rcTopLeft, "text:", strText, "layer:", layer) xyPixLeftTop = tuple((array(rcTopLeft) * self.nPixCell)[[1, 0]]) self.text(*xyPixLeftTop, strText, layer) @@ -606,7 +605,6 @@ class PILSVG(PILGL): self.draw_image_row_col(bg_svg, (row, col), layer=PILGL.SELECTED_AGENT_LAYER) if show_debug: - print("Call text:") self.text_rowcol((row + 0.2, col + 0.2,), str(agent_idx)) def set_cell_occupied(self, agent_idx, row, col): diff --git a/tests/test_flatland_envs_predictions.py b/tests/test_flatland_envs_predictions.py index d891ccaa..6139b0e2 100644 --- a/tests/test_flatland_envs_predictions.py +++ b/tests/test_flatland_envs_predictions.py @@ -155,7 +155,7 @@ def test_shortest_path_predictor(rendering=False): next_direction=1)), ShortestPathElement((3, 8), 1, RailEnvNextAction(action=RailEnvActions.MOVE_FORWARD, next_position=(3, 9), next_direction=1)), - ShortestPathElement((3, 9), 1, RailEnvNextAction(action=RailEnvActions.DO_NOTHING, next_position=(3, 9), + ShortestPathElement((3, 9), 1, RailEnvNextAction(action=RailEnvActions.STOP_MOVING, next_position=(3, 9), next_direction=1))] # extract the data -- GitLab