mirror of
https://github.com/maoakeEnterprise/amazing.git
synced 2026-04-28 16:04:35 +02:00
WIP: kruskal algorithm
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .classes.Cell import Cell
|
||||
|
||||
__version__ = "1.0.0"
|
||||
__author__ = "nous"
|
||||
__author__ = "us"
|
||||
__all__ = ["Cell"]
|
||||
|
||||
@@ -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
|
||||
@@ -3,5 +3,13 @@ import numpy as np
|
||||
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])
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user