def testCollision(self): """ test against a maze with outer/inner entraces """ starts = [True, False] ends = [True, False] for s in starts: for e in ends: m = self._create_maze_with_varied_entrances(s, e) m.solver = Collision() m.solve() for sol in m.solutions: self.assertFalse(self._duplicates_in_solution(sol)) self.assertTrue(self._one_away(m.start, sol[0])) self.assertTrue(self._one_away(m.end, sol[-1]))
def test_collision(self): """ test against a maze with outer/inner entraces """ starts = [True, False] ends = [True, False] for s in starts: for e in ends: m = self.create_maze_with_varied_entrances(s, e) m.solver = Collision() m.solve() for sol in m.solutions: assert not self.duplicates_in_solution(sol) assert self.one_away(m.start, sol[0]) assert self.one_away(m.end, sol[-1]) assert self.solution_is_sane(sol)
def testMonteCarlo(self): h = 4 w = 5 H = 2 * h + 1 W = 2 * w + 1 m = Maze() m.generator = Prims(h, w) m.solver = Collision() m.generate_monte_carlo(3) # grid size self.assertEqual(m.grid.shape[0], H) self.assertEqual(m.grid.shape[1], W) # test entrances are outer self.assertTrue(self._on_edge(m.grid, m.start)) self.assertTrue(self._on_edge(m.grid, m.end))
def test_monte_carlo_reducer(self): """ Test that the reducer functionality on the Monte Carlo maze generator """ h = 4 w = 5 H = 2 * h + 1 W = 2 * w + 1 m = Maze() m.generator = Prims(h, w) m.solver = Collision() m.generate_monte_carlo(3, reducer=self._num_turns) # grid size assert m.grid.shape[0] == H assert m.grid.shape[1] == W # test entrances are outer assert self._on_edge(m.grid, m.start) assert self._on_edge(m.grid, m.end)
def test_monte_carlo(self): """ Test that the basic Monte Carlo maze generator """ h = 4 w = 5 H = 2 * h + 1 W = 2 * w + 1 m = Maze() m.generator = Prims(h, w) m.solver = Collision() m.generate_monte_carlo(3) # grid size assert m.grid.shape[0] == H assert m.grid.shape[1] == W # test entrances are outer assert self._on_edge(m.grid, m.start) assert self._on_edge(m.grid, m.end)