From ff564ef6da3885bcbae7b566f9db1142d91719ef Mon Sep 17 00:00:00 2001 From: Axy Date: Thu, 5 Feb 2026 02:58:15 +0100 Subject: [PATCH] Fixed for non-square mazes --- __main__.py | 4 ++-- amazeing/display.py | 2 +- amazeing/maze.py | 5 +++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/__main__.py b/__main__.py index 8848e9e..d19e4a6 100644 --- a/__main__.py +++ b/__main__.py @@ -1,7 +1,7 @@ from amazeing import * import random -maze = Maze(10, 10) +maze = Maze(10, 30) maze.outline() empty = list(maze.walls_empty()) random.shuffle(empty) @@ -9,7 +9,7 @@ for wall in empty: if maze.wall_maintains_topology(wall): maze.fill_wall(wall) -backend = TTYBackend(10, 10) +backend = TTYBackend(10, 30) backend.set_style("#") for wall in maze.walls_full(): for pixel in wall.pixel_coords(): diff --git a/amazeing/display.py b/amazeing/display.py index 835e1a0..5d4f973 100644 --- a/amazeing/display.py +++ b/amazeing/display.py @@ -22,7 +22,7 @@ class TTYBackend(Backend): self.height: int = maze_height * 2 + 1 self.style: str = style self.lines: list[list[str]] = [ - [style for _ in range(0, self.width)] for _ in range(0, self.height) + [style for _ in range(0, self.height)] for _ in range(0, self.width) ] def draw_pixel(self, pos: PixelCoord) -> None: diff --git a/amazeing/maze.py b/amazeing/maze.py index 0a96aa9..8919b9f 100644 --- a/amazeing/maze.py +++ b/amazeing/maze.py @@ -93,8 +93,8 @@ class Maze: def all_walls(self) -> Generator[WallID]: for orientation, a_count, b_count in [ - (Orientation.HORIZONTAL, self.width + 1, self.height), - (Orientation.VERTICAL, self.height + 1, self.width), + (Orientation.HORIZONTAL, self.height + 1, self.width), + (Orientation.VERTICAL, self.width + 1, self.height), ]: for a in range(0, a_count): for b in range(0, b_count): @@ -162,6 +162,7 @@ class Maze: ]: for a in a_iter: for b in b_iter: + print(f"{a}, {b}, {orientation}") self.fill_wall(WallID(orientation, a, b)) def walls_full(self) -> Iterable[WallID]: -- 2.52.0