Skip to main content

Maze Generator and Solver using DFS

Project description

About Project

Maze Generator and Solver built with Python

Install Requirements

Currently, there is only one requirement for the project and that is the Pillow library.

Install the requirements using one of the following commands

Option #1
pip install -r requirements.txt

Option #2
py -m pip install -r requirements.txt

How to use Maze and MazeVisualizer

Use Maze and MazeVisulizer to open a GUI to view maze generation

from src.Maze import Maze
from src.MazeVisualizer import MazeVisualizer

# How to use Maze

# Create Maze with minimum arguments
maze = Maze(num_rows=40, num_cols=40)
# Starts generatring maze at (5, 10). End cell is set to (25, 15)
maze_2 = Maze(num_rows=60, num_cols=40, start_row=5, start_col=10, end_row=25, end_col=15) 
# If seed is provided, the seed is used to generate the maze
maze_3 = Maze(num_rows=20, num_cols=20, seed="test seed")

# How to use MazeVisualizer

# Create MazeVisualizer with minimum arguments
maze_visualizer = Maze(maze) # Opens GUI and the maze generation can be viewed

maze_visualizer2 = Maze(maze_2, cell_size=10) # Each cell in maze is cell_size pixels by cell_size pixels

maze_visualizer3 = Maze(maze_3, cell_size=10, delay_ms=2) # Delay (in milliseconds) between each maze update during maze generation

Exporting maze to image

Use Maze.to_image to export maze to png

from src.Maze import Maze 
maze = Maze(num_rows=40, num_cols=40)
maze.to_img(file_name="maze") # Creates maze.png
maze.to_img(file_name="maze_solution", solution=True) # Creates maze_solution.png (Image contains solution)
maze.to_img(file_name="maze_2", cell_size=10) # Creates maze_2.png where each cell is 10 pixels by 10 pixels

Exporting maze generation to gif

Use Maze.to_gif to export maze generation to gif

from src.Maze import Maze
maze = Maze(num_rows=40, num_cols=40)
maze.to_gif(file_name="maze") # Creates maze.gif
maze.to_gif(file_name="maze_2", cell_size=10) # Creates maze_2.gif where each cell is 10 pixels by 10 pixels

Exporting maze to txt file

Use Maze.to_txt to export maze to txt

from src.Maze import Maze
maze = Maze(num_rows=40, num_cols=40)
maze.to_txt() # Creates maze.txt
maze.to_txt(file_name="maze_2") # file_name can be supplied (maze_2.txt is created)
maze.to_txt(solution=True) # Populates txt with solution

Exporting maze to JSON

Use Maze.to_json to export maze to JSON.

See to_json() for JSON format

from src.Maze import Maze
maze = Maze(num_rows=40, num_cols=40)
json = maze.to_json()

Printing maze to console

Use Maze.print to print maze to console

from src.Maze import Maze
maze = Maze(num_rows=40, num_cols=40)
maze.print()
maze.print(show_solution=True) # Maze Text will include solution path

Maze

Exhaustive documentation for Maze

MazeVisualizer

Exhaustive documentation for MazeVisualizer

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

CamsMazes-1.0.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

CamsMazes-1.0.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file CamsMazes-1.0.0.tar.gz.

File metadata

  • Download URL: CamsMazes-1.0.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for CamsMazes-1.0.0.tar.gz
Algorithm Hash digest
SHA256 39b9f6254902604da5539aab19cf6df89cbb8b86fbbb6a82ab8b74ba53c243fc
MD5 e3d1d56375754fdfe3e9d77171559ccf
BLAKE2b-256 4629f04e75b7e51d6b4a21a74f402223ace36eaa10cd4913b2bd8a21a8491ce6

See more details on using hashes here.

File details

Details for the file CamsMazes-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: CamsMazes-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.1

File hashes

Hashes for CamsMazes-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c0c88bf5f573fc1ab916f36602a4c9ee2e9b7bdca140ab831630cbfbb39e55e7
MD5 b7b147f6ef2f5f48a2e8e6766df6827e
BLAKE2b-256 65c10fa0eca936c81f590753e40ba77514e38a0eae95fe8a3ba7a06d6524a375

See more details on using hashes here.

Supported by

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