diff --git a/Makefile b/Makefile index 80ba7cd..820b211 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ debug: uv pdb python3 a_maze_ing.py config.txt clean: - rm -rf */**__pycache__ __pycache__ .mypy_cache .venv dist build */**/*.egg-info *.egg-info + rm -rf */**/__pycache__ __pycache__ .mypy_cache .venv dist build */**/*.egg-info *.egg-info test.txt fclean: clean rm mazegen-1.0.0-py3-none-any.whl diff --git a/a_maze_ing.py b/a_maze_ing.py index 44ba645..11a7d1e 100644 --- a/a_maze_ing.py +++ b/a_maze_ing.py @@ -309,7 +309,8 @@ class MazeMLX: def draw_ft( self, maze: NDArray[Any], color: list[Any] | None = None ) -> None: - """Draw filled cells corresponding to the reserved fully walled pattern. + """Draw filled cells corresponding to the reserved fully + walled pattern. Args: maze: Maze grid to inspect. diff --git a/src/AMazeIng.py b/src/AMazeIng.py index 7715291..8af39c9 100644 --- a/src/AMazeIng.py +++ b/src/AMazeIng.py @@ -6,7 +6,9 @@ from .amaz_lib import Maze, MazeGenerator, MazeSolver class AMazeIng(BaseModel): - """Represent a complete maze configuration, generation, and solving setup.""" + """Represent a complete maze configuration, generation, + and solving setup. + """ model_config = ConfigDict(arbitrary_types_allowed=True) diff --git a/src/amaz_lib/MazeGenerator.py b/src/amaz_lib/MazeGenerator.py index 3ec2a61..866763a 100644 --- a/src/amaz_lib/MazeGenerator.py +++ b/src/amaz_lib/MazeGenerator.py @@ -84,7 +84,8 @@ class MazeGenerator(ABC): forty_two: set[tuple[int, int]] | None, prob: float = 0.1, ) -> Generator[NDArray[Any], None, NDArray[Any]]: - """Add extra openings to transform a perfect maze into an imperfect one. + """Add extra openings to transform a perfect maze into an imperfect + one. Random walls are removed while optionally preserving the reserved ``forty_two`` area. @@ -116,7 +117,9 @@ class MazeGenerator(ABC): continue for direc, (dx, dy) in directions.items(): nx, ny = x + dx, y + dy - if forty_two and ((y, x) in forty_two or (ny, nx) in forty_two): + if forty_two and ( + (y, x) in forty_two or (ny, nx) in forty_two + ): continue if not (0 <= nx < width and 0 < ny < height): continue @@ -241,7 +244,9 @@ class Kruskal(MazeGenerator): a in sets.sets[i].cells or b in sets.sets[i].cells ): base_set = sets.sets[i] - elif base_set and (a in sets.sets[i].cells or b in sets.sets[i].cells): + elif base_set and ( + a in sets.sets[i].cells or b in sets.sets[i].cells + ): base_set.cells += sets.sets[i].cells sets.sets.pop(i) return @@ -426,9 +431,12 @@ class DepthFirstSearch(MazeGenerator): height: Number of rows in the maze. Returns: - A two-dimensional array of cells initialized with all walls present. + A two-dimensional array of cells initialized with all + walls present. """ - maze = np.array([[Cell(value=15) for _ in range(width)] for _ in range(height)]) + maze = np.array( + [[Cell(value=15) for _ in range(width)] for _ in range(height)] + ) return maze @staticmethod @@ -546,7 +554,8 @@ class DepthFirstSearch(MazeGenerator): w_h: tuple[int, int], visited: NDArray[Any], ) -> list[tuple[int, int]]: - """Backtrack through the path until a cell with unvisited neighbors is found. + """Backtrack through the path until a cell with unvisited neighbors + is found. Args: path: Current traversal path. diff --git a/src/amaz_lib/__init__.py b/src/amaz_lib/__init__.py index 2c20d16..f89d378 100644 --- a/src/amaz_lib/__init__.py +++ b/src/amaz_lib/__init__.py @@ -6,5 +6,13 @@ from .MazeSolver import MazeSolver, AStar, DepthFirstSearchSolver __version__ = "1.0.0" __author__ = "us" -__all__ = ["Cell", "Maze", "MazeGenerator", "DepthFirstSearchSolver", - "MazeSolver", "AStar", "Kruskal", "DepthFirstSearch"] +__all__ = [ + "Cell", + "Maze", + "MazeGenerator", + "DepthFirstSearchSolver", + "MazeSolver", + "AStar", + "Kruskal", + "DepthFirstSearch", +] diff --git a/src/parsing/Parsing.py b/src/parsing/Parsing.py index c2d8d99..a54ced2 100644 --- a/src/parsing/Parsing.py +++ b/src/parsing/Parsing.py @@ -79,8 +79,8 @@ class DataMaze: data: Raw configuration dictionary with string values. Returns: - A dictionary containing converted values and instantiated solver and - generator objects. + A dictionary containing converted values and instantiated + solver and generator objects. """ key_int = {"WIDTH", "HEIGHT"} key_tuple = {"ENTRY", "EXIT"}