Skip to main content

Implementation of maze-related algorithms

Project description

Solved 32x128 maze

mazely

MIT License Read the Docs

An API for solving and generating mazes, written in Python.

Documentation

A library reference can be found here.

Usage examples

Run the Python scripts below from the repository directory.

Also, see the examples folder.

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.

from mazely import Maze, Utilities

maze = Maze(path="resources/2015apec.maze")
utils = Utilities()
utils.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.

from mazely import Maze, Utilities

maze = Maze(path="resources/2019japan.maze")
utils = Utilities()
utils.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.

from mazely import Maze, Utilities

maze = Maze(32, 32)
utils = Utilities()
utils.show_solution()

Solved 32x32 maze

Maze files

The library only supports a single maze format, as specified below.

File format

Each cell is 3 characters wide and 3 characters tall.

+---+
|   |
+---+

To specify the goal cell, replace the center with G.

+---+
| G |
+---+

And replace with S for the start cell.

+---+
| S |
+---+

Here is an example of a 3x3 maze.

+---+---+---+
|           |
+   +---+   +
|     G |   |
+---+---+   +
| S         |
+---+---+---+

Links

Here are a couple links to collections of maze files (format may not be supported):

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mazely-0.1.1.tar.gz (9.8 kB view hashes)

Uploaded Source

Built Distribution

mazely-0.1.1-py3-none-any.whl (11.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page