WIP: kruskal algorithm

This commit is contained in:
2026-03-16 16:48:04 +01:00
parent ce584d2ae3
commit b44cffec2c
3 changed files with 25 additions and 2 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
from .classes.Cell import Cell from .classes.Cell import Cell
__version__ = "1.0.0" __version__ = "1.0.0"
__author__ = "nous" __author__ = "us"
__all__ = ["Cell"] __all__ = ["Cell"]
+15
View File
@@ -0,0 +1,15 @@
from sys import stdout
import numpy as np
from pydantic import BaseModel
class Maze(BaseModel):
maze: np.ndarray
def __str__(self) -> str:
res = ""
for _ in self.maze:
for cell in self.maze:
res += cell
res += "\n"
return res
+9 -1
View File
@@ -3,5 +3,13 @@ import numpy as np
from .. import Cell from .. import Cell
def kraskal(height: int, width: int) -> Generator[None, None, None]: def kraskal(
height: int, width: int
) -> Generator[np.ndarray, None, np.ndarray]:
maze = np.array([[Cell(value=15) for _ in range(height)] * width]) maze = np.array([[Cell(value=15) for _ in range(height)] * width])
cells_checked = np.array([[False for _ in range(height)] * width])
excepted_end = np.array([[True for _ in range(height)] * width])
while cells_checked != excepted_end:
yield maze
return maze