Visualise maze generation and pathfinding algorithms with Pygame.
Clone this repo and cd into it:
git clone https://github.com/ChrisKneller/pygame-pathfinder.git
cd pygame-pathfinder
Create and activate your virtual environment:
- MacOS/Linux:
virtualenv --no-site-packages env
source env/bin/activate
- Windows:
virtualenv env
.\env\Scripts\activate
Install the required packages:
pip install -r requirements.txt
python grid.py
Maze/terrain generation buttons are on the right.
Pathfinding buttons are on the left.
The visualise button is a toggle.
Left click to create a wall or move the start and end points.
Hold left CTRL and left click to create a sticky mud patch (which reduces movement speed to 1/3).
The point of these mud patches is to showcase Dijkstra's algorithm (first) and A* (second) by adjusting the "distances" between the nodes:
After a pathfinding algorithm has been run you can drag the start/end points around and see the visualisation update instantly for the new path using the algorithm that was last run.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.