mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
fix lint + black formating + SITULITUPU
This commit is contained in:
@@ -16,7 +16,7 @@ debug:
|
|||||||
uv pdb python3 a_maze_ing.py config.txt
|
uv pdb python3 a_maze_ing.py config.txt
|
||||||
|
|
||||||
clean:
|
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
|
fclean: clean
|
||||||
rm mazegen-1.0.0-py3-none-any.whl
|
rm mazegen-1.0.0-py3-none-any.whl
|
||||||
|
|||||||
+2
-1
@@ -309,7 +309,8 @@ class MazeMLX:
|
|||||||
def draw_ft(
|
def draw_ft(
|
||||||
self, maze: NDArray[Any], color: list[Any] | None = None
|
self, maze: NDArray[Any], color: list[Any] | None = None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Draw filled cells corresponding to the reserved fully walled pattern.
|
"""Draw filled cells corresponding to the reserved fully
|
||||||
|
walled pattern.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
maze: Maze grid to inspect.
|
maze: Maze grid to inspect.
|
||||||
|
|||||||
+3
-1
@@ -6,7 +6,9 @@ from .amaz_lib import Maze, MazeGenerator, MazeSolver
|
|||||||
|
|
||||||
|
|
||||||
class AMazeIng(BaseModel):
|
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)
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ class MazeGenerator(ABC):
|
|||||||
forty_two: set[tuple[int, int]] | None,
|
forty_two: set[tuple[int, int]] | None,
|
||||||
prob: float = 0.1,
|
prob: float = 0.1,
|
||||||
) -> Generator[NDArray[Any], None, NDArray[Any]]:
|
) -> 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
|
Random walls are removed while optionally preserving the reserved
|
||||||
``forty_two`` area.
|
``forty_two`` area.
|
||||||
@@ -116,7 +117,9 @@ class MazeGenerator(ABC):
|
|||||||
continue
|
continue
|
||||||
for direc, (dx, dy) in directions.items():
|
for direc, (dx, dy) in directions.items():
|
||||||
nx, ny = x + dx, y + dy
|
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
|
continue
|
||||||
if not (0 <= nx < width and 0 < ny < height):
|
if not (0 <= nx < width and 0 < ny < height):
|
||||||
continue
|
continue
|
||||||
@@ -241,7 +244,9 @@ class Kruskal(MazeGenerator):
|
|||||||
a in sets.sets[i].cells or b in sets.sets[i].cells
|
a in sets.sets[i].cells or b in sets.sets[i].cells
|
||||||
):
|
):
|
||||||
base_set = sets.sets[i]
|
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
|
base_set.cells += sets.sets[i].cells
|
||||||
sets.sets.pop(i)
|
sets.sets.pop(i)
|
||||||
return
|
return
|
||||||
@@ -426,9 +431,12 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
height: Number of rows in the maze.
|
height: Number of rows in the maze.
|
||||||
|
|
||||||
Returns:
|
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
|
return maze
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -546,7 +554,8 @@ class DepthFirstSearch(MazeGenerator):
|
|||||||
w_h: tuple[int, int],
|
w_h: tuple[int, int],
|
||||||
visited: NDArray[Any],
|
visited: NDArray[Any],
|
||||||
) -> list[tuple[int, int]]:
|
) -> 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:
|
Args:
|
||||||
path: Current traversal path.
|
path: Current traversal path.
|
||||||
|
|||||||
@@ -6,5 +6,13 @@ from .MazeSolver import MazeSolver, AStar, DepthFirstSearchSolver
|
|||||||
|
|
||||||
__version__ = "1.0.0"
|
__version__ = "1.0.0"
|
||||||
__author__ = "us"
|
__author__ = "us"
|
||||||
__all__ = ["Cell", "Maze", "MazeGenerator", "DepthFirstSearchSolver",
|
__all__ = [
|
||||||
"MazeSolver", "AStar", "Kruskal", "DepthFirstSearch"]
|
"Cell",
|
||||||
|
"Maze",
|
||||||
|
"MazeGenerator",
|
||||||
|
"DepthFirstSearchSolver",
|
||||||
|
"MazeSolver",
|
||||||
|
"AStar",
|
||||||
|
"Kruskal",
|
||||||
|
"DepthFirstSearch",
|
||||||
|
]
|
||||||
|
|||||||
@@ -79,8 +79,8 @@ class DataMaze:
|
|||||||
data: Raw configuration dictionary with string values.
|
data: Raw configuration dictionary with string values.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
A dictionary containing converted values and instantiated solver and
|
A dictionary containing converted values and instantiated
|
||||||
generator objects.
|
solver and generator objects.
|
||||||
"""
|
"""
|
||||||
key_int = {"WIDTH", "HEIGHT"}
|
key_int = {"WIDTH", "HEIGHT"}
|
||||||
key_tuple = {"ENTRY", "EXIT"}
|
key_tuple = {"ENTRY", "EXIT"}
|
||||||
|
|||||||
Reference in New Issue
Block a user