Skip to content

N-NeelPatel/PyMaze

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyMaze

PyMaze is a Python application that generates a random maze and solves it using the A* algorithm. The application is designed to allow users to input the size of the maze, starting and ending points, and also specify the density of walls.

The A* algorithm implementation is optimized for performance and the application has the ability to extend with other algorithms as well. To visualize the solution path, tkinter, a Python library, is used. The solution path can be saved as a GIF animation.

How to use

To use the application simply run the main.py file and it will ask for values for the parameters like, height of the maze, width of the maze, x and y coordinates for the starting and ending points, wall density for the walls. Provide these information and it will create a random maze and solve it visually using tkinter.

Solution Approach

  • A random maze is created using recursive backtracking algorithm based on user inputs
  • Then based on the starting and ending coordinates, A*(a-star) algorithm is used to find the optimal path from start to end points
  • Then an agent is created and place in the maze to walk on the maze
  • The path generated from A*(a-star) algorithm is then traced back using the agent to show the solution visually.
  • Solution gif is also generated in the end

Code Structure

  • src/theme.py - Contains an enum of themes that are used by maze and agent files.
  • src/agent.py - Contains code for creating an agent that traverses through the maze
  • src/maze.py - Contains code for creating a random maze, saving a maze, loading a maze and much more which related to maze. This code is then used by the main driver of the application.
  • main.py - the driver of the application, imports all the information from the src package and contains the A*(a-star) algorithm and it is expected to run the main.py file providing all the paramters of the puzzle.

Screenshots

1 2 3

About

py-maze application in python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages