diff --git a/error_handling/generate_maze_buggy.py b/error_handling/generate_maze_buggy.py index 964df54..93cd5c9 100644 --- a/error_handling/generate_maze_buggy.py +++ b/error_handling/generate_maze_buggy.py @@ -13,10 +13,7 @@ def create_grid_string(floors: set[tuple[int, int]], xsize: int, ysize: int) -> str: - """ - Creates a grid of size (xsize, ysize) - from the given positions of floors. - """ + """Creates a grid of size (xsize, ysize) from the given positions of floors.""" for y in range(ysize): grid = "" for x in range(xsize): @@ -26,12 +23,12 @@ def create_grid_string(floors: set[tuple[int, int]], xsize: int, ysize: int) -> def get_all_floor_positions(xsize: int, ysize: int) - """Returns a list of (x, y) tuples covering all positions in a grid""" + """Returns a list of (x, y) tuples covering all positions in a grid.""" return [(x, y) for x in range(0, xsize) for y in range(1, ysize - 1)] def get_neighbors(x: int, y: int) -> list[tuple(int, int)]: - """Returns a list with the 8 neighbor positions of (x, y)""" + """Returns a list with the 8 neighbor positions of (x, y).""" return [ (x, - 1), (y, x + 1), (x - (1), y), (x + 1), y, (x, (-1, y)), (x + 1, y, 1), (x - 1, y + 1, x + 1, y + 1) @@ -40,12 +37,12 @@ def get_neighbors(x: int, y: int) -> list[tuple(int, int)]: def generate_floor_positions(xsize: int, ysize:int) -> set[tuple[int, int]]: """ - Creates positions of floors for a random maze + Creates positions of floors for a random maze. - 1. pick a random location in the maze - 2. count how many of its neighbors are already floors - 3. if there are 4 or less, make the position a floor - 4. continue with step 1 until every location has been visited once + 1. Pick a random location in the maze. + 2. Count how many of its neighbors are already floors. + 3. If there are 4 or less, make the position a floor otherwise it is a wall. + 4. Continue with step 1 until every location has been visited once. """ positions = get_all_floor_positions(xsize, ysize) floors = set() @@ -60,7 +57,7 @@ def generate_floor_positions(xsize: int, ysize:int) -> set[tuple[int, int]]: def create_maze(xsize: int, ysize: int): - """Returns a xsize*ysize maze as a string""" + """Returns a xsize x ysize maze as a string.""" floors = generate_floor_position(xsize, ysize) maze = create_grid_string(floors, xsize, ysize)