From a1d5dbe79468d4792dbdf01f2f8071da31ef9a9b Mon Sep 17 00:00:00 2001 From: MLErik <baerenjesus@gmail.com> Date: Thu, 3 Oct 2019 10:58:56 -0400 Subject: [PATCH] catch non-straight line in connect_line function --- flatland/envs/grid4_generators_utils.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/flatland/envs/grid4_generators_utils.py b/flatland/envs/grid4_generators_utils.py index 089cea5e..042e3c5f 100644 --- a/flatland/envs/grid4_generators_utils.py +++ b/flatland/envs/grid4_generators_utils.py @@ -80,7 +80,21 @@ def connect_basic_operation( def connect_line(rail_trans, grid_map, start, end, openend=False): - # Set start cell + """ + Generates a straight rail line from start cell to end cell. + Diagonal lines are not allowed + :param rail_trans: + :param grid_map: + :param start: Cell coordinates for start of line + :param end: Cell coordinates for end of line + :param openend: If True then the transition at start and end is set to 0: An empty cell + :return: A list of all cells in the path + """ + + # Assert that a straight line is possible + if not (start[0] == end[0] or start[1] == end[1]): + print("No line possible") + return [] current_cell = start path = [current_cell] new_trans = grid_map.grid[current_cell] -- GitLab