Usage Examples#

Examples of use.

Load and display a maze#

Create an instance of Maze and pass a path to a maze file to load an existing maze. Use the show_grid() method from Utilities to display a grid of the maze.

1from mazely import Maze, Utilities
2
3maze = Maze(path="resources/2015apec.maze")
4utils = Utilities()
5utils.show_grid(maze.grid)
APEC 2015

Solve a maze and display its solution#

A solution is always made when you create an instance of Maze. To display the solution, use the show_solution() method from Utilities.

1from mazely import Maze, Utilities
2
3maze = Maze(path="resources/2019japan.maze")
4utils = Utilities()
5utils.show_solution()
Japan 2019

Generate a maze and display its solution#

To generate a maze, pass the row and column counts as you create a Maze instance. Refer to the previous section to display its solution.

1from mazely import Maze, Utilities
2
3maze = Maze(32, 32)
4utils = Utilities()
5utils.show_solution()
Solved 32x32 maze