Doors don't break the connexity of map
This commit is contained in:
parent
11daa8573c
commit
8f845d1e4c
|
@ -27,15 +27,16 @@ class TestBroguelike(unittest.TestCase):
|
|||
def is_connex(self, grid: List[List[Tile]]) -> bool:
|
||||
h, w = len(grid), len(grid[0])
|
||||
y, x = randint(0, h - 1), randint(0, w - 1)
|
||||
while not (grid[y][x].can_walk()):
|
||||
while not (grid[y][x].can_walk() or grid[y][x] == Tile.DOOR):
|
||||
y, x = randint(0, h - 1), randint(0, w - 1)
|
||||
queue = Map.neighbourhood(grid, y, x)
|
||||
while queue:
|
||||
y, x = queue.pop()
|
||||
if grid[y][x].can_walk():
|
||||
if grid[y][x].can_walk() or grid[y][x] == Tile.DOOR:
|
||||
grid[y][x] = Tile.WALL
|
||||
queue += Map.neighbourhood(grid, y, x)
|
||||
return not any([t.can_walk() for row in grid for t in row])
|
||||
return not any([t.can_walk() or t == Tile.DOOR
|
||||
for row in grid for t in row])
|
||||
|
||||
def test_build_doors(self) -> None:
|
||||
m = self.stom(". .\n. .\n. .\n")
|
||||
|
|
Loading…
Reference in New Issue