Пример #1
0
    def testDungeonRoomsRooms(self):
        m = Maze()
        m.generator = DungeonRooms(4, 4, rooms=[[(1,1), (3,3)]])
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
Пример #2
0
    def testDungeonRoomsRooms(self):
        m = Maze()
        m.generator = DungeonRooms(4, 4, rooms=[[(1, 1), (3, 3)]])
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
Пример #3
0
    def testCellularAutomaton(self):
        m = Maze()
        m.generator = CellularAutomaton(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
Пример #4
0
    def test_cellular_automaton(self):
        m = Maze()
        m.generator = CellularAutomaton(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
Пример #5
0
    def testWilsons(self):
        m = Maze()
        m.generator = Wilsons(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #6
0
    def testHuntAndKill(self):
        m = Maze()
        m.generator = HuntAndKill(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #7
0
    def testCellularAutomaton(self):
        m = Maze()
        m.generator = CellularAutomaton(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #8
0
    def test_binary_tree(self):
        m = Maze()
        m.generator = BinaryTree(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #9
0
    def test_division(self):
        m = Maze()
        m.generator = Division(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #10
0
    def testBacktrackingGenerator(self):
        m = Maze()
        m.generator = BacktrackingGenerator(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #11
0
    def test_hunt_and_kill_serpentine_order(self):
        m = Maze()
        m.generator = HuntAndKill(4, 5, 'serpentine')
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #12
0
    def testDivision(self):
        m = Maze()
        m.generator = Division(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #13
0
    def test_wilsons_serpentine_order(self):
        m = Maze()
        m.generator = Wilsons(4, 5, hunt_order='serpentine')
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #14
0
    def test_sidewinder(self):
        m = Maze()
        m.generator = Sidewinder(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #15
0
    def testHuntAndKill(self):
        m = Maze()
        m.generator = HuntAndKill(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #16
0
    def test_aldous_broder(self):
        m = Maze()
        m.generator = AldousBroder(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #17
0
    def test_backtracking_generator(self):
        m = Maze()
        m.generator = BacktrackingGenerator(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #18
0
    def test_cellular_automaton(self):
        """ test the Cellulator Automaton method generates a reasonably sane maze """
        m = Maze()
        m.generator = CellularAutomaton(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
Пример #19
0
    def testAldousBroder(self):
        m = Maze()
        m.generator = AldousBroder(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #20
0
    def testGrowingTree(self):
        m = Maze()
        m.generator = GrowingTree(4, 5)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #21
0
    def test_binary_tree(self):
        """ test the Binary Tree method generates a reasonably sane maze """
        m = Maze()
        m.generator = BinaryTree(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #22
0
    def test_backtracking_generator(self):
        """ test the Backtracking method generates a reasonably sane maze """
        m = Maze()
        m.generator = BacktrackingGenerator(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #23
0
    def test_aldous_broder(self):
        """ test the AlgousBroder method generates a reasonably sane maze """
        m = Maze()
        m.generator = AldousBroder(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #24
0
    def test_wilsons_serpentine_order(self):
        """ test the Wilson method generates a reasonably sane maze, using the serpentine pathway """
        m = Maze()
        m.generator = Wilsons(4, 5, hunt_order='serpentine')
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #25
0
    def test_sidewinder(self):
        """ test the Sidewinder method generates a reasonably sane maze """
        m = Maze()
        m.generator = Sidewinder(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #26
0
    def test_kruskal(self):
        """ test the Kruskal method generates a reasonably sane maze """
        m = Maze()
        m.generator = Kruskal(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #27
0
    def test_division(self):
        """ test the Division method generates a reasonably sane maze """
        m = Maze()
        m.generator = Division(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #28
0
    def test_hunt_and_kill_serpentine_order(self):
        """ test the Hunt and Kill method generates a reasonably sane maze, using the serpentine pathway """
        m = Maze()
        m.generator = HuntAndKill(4, 5, 'serpentine')
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
Пример #29
0
    def test_trivial_maze_spiral(self):
        m = Maze()
        m.generator = TrivialMaze(4, 5)
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #30
0
    def test_trivial_maze_spiral(self):
        """ test that the trivial/spiral maze is reasonably sane """
        m = Maze()
        m.generator = TrivialMaze(4, 5)
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
        assert all_corners_complete(m.grid)
        assert all_corners_complete(m.grid)
Пример #31
0
    def test_trivial_maze_serpentine(self):
        # run this test enough times to trip the different skewness parameters
        for _ in range(10):
            m = Maze()
            m.generator = TrivialMaze(4, 5, 'serpentine')
            m.generate()

            self.assertTrue(boundary_is_solid(m.grid))
            self.assertTrue(all_passages_open(m.grid))
            self.assertTrue(all_corners_complete(m.grid))
Пример #32
0
    def test_dungeon_rooms_serpentine_rooms(self):
        m = Maze()
        m.generator = DungeonRooms(4,
                                   4,
                                   rooms=[[(1, 1), (3, 3)]],
                                   hunt_order='serpentine')
        m.generate()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
Пример #33
0
    def testInnerEntrances(self):
        h = 4
        w = 5

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()
        m.generate_entrances(False, False)

        self.assertFalse(self._on_edge(m.grid, m.start))
        self.assertFalse(self._on_edge(m.grid, m.end))
Пример #34
0
    def testOuterEntrances(self):
        h = 4
        w = 5

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()
        m.generate_entrances()

        self.assertTrue(self._on_edge(m.grid, m.start))
        self.assertTrue(self._on_edge(m.grid, m.end))
Пример #35
0
    def test_dungeon_rooms_serpentine_rooms(self):
        """ test DungeonRooms mazes are reasonably when generating some random rooms in a serpentine fashion """
        m = Maze()
        m.generator = DungeonRooms(4,
                                   4,
                                   rooms=[[(1, 1), (3, 3)]],
                                   hunt_order='serpentine')
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
Пример #36
0
    def testInnerEntrances(self):
        h = 4
        w = 5

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()
        m.generate_entrances(False, False)

        self.assertFalse(self._on_edge(m.grid, m.start))
        self.assertFalse(self._on_edge(m.grid, m.end))
Пример #37
0
    def testOuterEntrances(self):
        h = 4
        w = 5

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()
        m.generate_entrances()

        self.assertTrue(self._on_edge(m.grid, m.start))
        self.assertTrue(self._on_edge(m.grid, m.end))
Пример #38
0
    def test_perturbation(self):
        m = Maze()
        m.generator = TrivialMaze(4, 5)
        m.generate()

        m.transmuters = [Perturbation()]
        m.transmute()

        self.assertTrue(boundary_is_solid(m.grid))
        self.assertTrue(all_passages_open(m.grid))
        self.assertTrue(all_corners_complete(m.grid))
Пример #39
0
    def test_dungeon_rooms_random_rooms(self):
        """ test Dungeon Rooms maze-creation mazes a reasonably sane maze when generating some random rooms """
        m = Maze()
        m.generator = DungeonRooms(4,
                                   4,
                                   rooms=[[(1, 1), (3, 3)]],
                                   hunt_order='random')
        m.generate()

        assert boundary_is_solid(m.grid)
        assert all_passages_open(m.grid)
Пример #40
0
    def testGridSize(self):
        h = 4
        w = 5
        H = 2 * h + 1
        W = 2 * w + 1

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()

        self.assertEqual(m.grid.shape[0], H)
        self.assertEqual(m.grid.shape[1], W)
Пример #41
0
    def testGridSize(self):
        h = 4
        w = 5
        H = 2 * h + 1
        W = 2 * w + 1

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()

        self.assertEqual(m.grid.height, H)
        self.assertEqual(m.grid.width, W)
Пример #42
0
    def testPerturbation(self):
        m1 = Maze()
        m1.generator = TrivialMaze(4, 5)
        m1.generate()

        m = Maze()
        m.generator = Perturbation(m1.grid)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
        self.assertTrue(self.all_corners_complete(m.grid))
Пример #43
0
    def testGeneratorWipe(self):
        h = 4
        w = 5

        m = Maze()
        m.generator = Prims(h, w)
        m.generate()
        m.generate_entrances()
        m.generate()

        self.assertTrue(m.start is None)
        self.assertTrue(m.end is None)
        self.assertTrue(m.solutions is None)
Пример #44
0
    def testDungeonRoomsGrid(self):
        g = np.ones((7, 7), dtype=np.int8)
        g[1] = [1,1,1,1,1,1,1]
        g[2] = [1,1,1,1,1,1,1]
        g[3] = [1,1,0,0,0,1,1]
        g[4] = [1,1,0,0,0,1,1]
        g[5] = [1,1,0,0,0,1,1]

        m = Maze()
        m.generator = DungeonRooms(4, 4, grid=g)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
Пример #45
0
    def testDungeonRoomsGrid(self):
        g = MazeArray(7, 7)
        g[1] = array('b', [1,1,1,1,1,1,1])
        g[2] = array('b', [1,1,1,1,1,1,1])
        g[3] = array('b', [1,1,0,0,0,1,1])
        g[4] = array('b', [1,1,0,0,0,1,1])
        g[5] = array('b', [1,1,0,0,0,1,1])

        m = Maze()
        m.generator = DungeonRooms(4, 4, grid=g)
        m.generate()

        self.assertTrue(self.boundary_is_solid(m.grid))
        self.assertTrue(self.all_passages_open(m.grid))
Пример #46
0
    def _create_maze_with_varied_entrances(self, start_outer=True, end_outer=True):
        """create a maze with entrances inside/outside"""
        m = Maze()
        m.generator = Prims(4, 5)
        m.generate()

        if start_outer and end_outer:
            m.generate_entrances()
        elif not start_outer and not end_outer:
            m.generate_entrances(False, False)
        elif start_outer:
             m.generate_entrances(True, False)
        else:
             m.generate_entrances(False, True)

        return m