Esempio n. 1
0
    def test_size_0(self):
        """Test whether generate_maze returns an empty numpy array on size 0"""

        maze = MazeGenerator.generate_maze(0)
        self.assertEqual(1, len(maze))
        self.assertEqual(1, len(maze[0]))
        self.assertEqual(0, len(maze[0][0]))
Esempio n. 2
0
    def test_completeness(self):
        """Use Breadth-First-Search to test that maze graph is complete (all nodes connected)
        The number of visited nodes should be equal to the maze's size"""

        for length in [1, 5, 20, 50, 100]:
            maze = MazeGenerator.generate_maze(length)
            self.assertEqual(len(maze)**2, self.bfs(maze))
Esempio n. 3
0
def make_maze(length):  # is this kind of method pythonic?
    """
    Factory method for making mazes that are already pre-generated at the specified size

    :param length: the dimensions of the maze (length X length)
    :return: Maze Object
    """
    return Maze(MazeGenerator.generate_maze(length))
Esempio n. 4
0
    def test_size(self):
        """Test whether generate_maze returns a numpy array of the proper size
        and dimensions for several inputs"""

        lengths = [1, 5, 10]
        for i in lengths:
            maze = MazeGenerator.generate_maze(i)
            self.assertEqual(i, len(maze))
            self.assertEqual((i), len(maze[0]))