Fix is_connex tests

This commit is contained in:
Charles Peyrat 2021-01-08 16:21:16 +01:00
parent 0aa4eb9c0b
commit a390f4f5e9

View File

@ -2,6 +2,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later
import unittest
from random import randint
from squirrelbattle.interfaces import Map, Tile
from squirrelbattle.mapgeneration import randomwalk, broguelike
@ -14,13 +15,10 @@ def is_connex(grid):
queue = Map.neighbourhood(grid, y, x)
while queue != []:
y, x = queue.pop()
if m.tiles[y][x].can_walk():
m.tiles[y][x] = Tile.WALL
if grid[y][x].can_walk():
grid[y][x] = Tile.WALL
queue += Map.neighbourhood(grid, y, x)
return not(any([any([t.can_walk() for t in l]) for l in m.tiles]))
return not(any([any([t.can_walk() for t in l]) for l in grid]))
class TestRandomWalk(unittest.TestCase):
def setUp(self) -> None:
@ -47,4 +45,4 @@ class TestBroguelike(unittest.TestCase):
def test_connexity(self) -> None:
m = self.generator.run()
self.assertTrue(is_connex(m))
self.assertTrue(is_connex(m.tiles))