finish the generator DFS

This commit is contained in:
Maoake Teriierooiterai
2026-03-24 14:28:10 +01:00
parent 8b4ef7afce
commit 4d151664ab
5 changed files with 44 additions and 46 deletions
+3 -11
View File
@@ -13,23 +13,15 @@ class TestDepth:
def test_rand_cells(self) -> None:
w_h = (10, 10)
lst = DepthFirstSearch.add_cell_visited((0, 0), set())
lst = np.zeros((10, 10), dtype=bool)
lst[0, 0] = True
rand_cells = DepthFirstSearch.random_cells(lst, (0, 1), w_h)
assert len(rand_cells) == 2
def test_next_cell(self) -> None:
coord = (5, 4)
x, y = coord
assert DepthFirstSearch.next_cell(x, y, "N") == (5, 3)
assert DepthFirstSearch.next_cell(x, y, "N") == (2, 3)
def test_reverse_path(self) -> None:
assert DepthFirstSearch.reverse_path("N") == "S"
def test_BOS(self) -> None:
path = {(0, 0), (0, 2), (1, 1)}
assert len(DepthFirstSearch.random_cells(path, (0, 1), (10, 10))) == 0
def test_generator(self):
maze = np.array([])
maze = DepthFirstSearch.generator(10, 10)
assert maze.shape == (10, 10)
+8 -7
View File
@@ -1,18 +1,19 @@
import numpy
from amaz_lib.MazeGenerator import DepthFirstSearch
from amaz_lib.MazeGenerator import Kruskal
class TestMazeGenerator:
# def test_kruskal_output_shape() -> None:
# generator = Kruskal()
# maze = numpy.array([])
# for output in generator.generator(10, 10):
# maze = output
def test_kruskal_output_shape() -> None:
generator = Kruskal().generator(10, 10)
maze = numpy.array([])
for output in generator:
maze = output
# assert maze.shape == (10, 10)
assert maze.shape == (10, 10)
def test_generator(self):
def test_generator(self) -> None:
maze = numpy.array([])
maze = DepthFirstSearch.generator(10, 10)
assert maze.shape == (10, 10)