https://github.com/sahil352005/pathfinding-simulation
Simple Pathfinding Simulation Using Different Algorithms
https://github.com/sahil352005/pathfinding-simulation
contributors
Last synced: 10 months ago
JSON representation
Simple Pathfinding Simulation Using Different Algorithms
- Host: GitHub
- URL: https://github.com/sahil352005/pathfinding-simulation
- Owner: sahil352005
- Created: 2024-10-01T15:55:27.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-08T14:08:34.000Z (over 1 year ago)
- Last Synced: 2025-06-01T09:15:36.115Z (about 1 year ago)
- Topics: contributors
- Language: Python
- Homepage: https://pathfinding-simulation.vercel.app
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
# Pathfinding Algorithm Visualizer
This is a visualizer tool for various pathfinding algorithms, implemented using **Pygame**. It allows you to see how algorithms like A*, Dijkstra, Breadth-First Search (BFS), and Depth-First Search (DFS) explore the grid to find the shortest path between two points. The tool also includes interactive features to create barriers, reset the grid, and choose the algorithm.
## Features
- **Visualization of Algorithms**: Visualize A*, Dijkstra, BFS, and DFS in real-time.
- **Interactive Grid**: Click to create barriers, set start/end points, and reset the grid.
- **Algorithm Selection**: Choose the pathfinding algorithm from a dropdown menu.
- **User Controls**:
- **Left Click**: Set the start, end, and barriers on the grid.
- **Right Click**: Remove barriers or reset points.
- **Run Button**: Start the selected algorithm.
- **Reset Button**: Reset the grid and start a new simulation.
## Algorithms
- **A***: A heuristic-based algorithm that combines the cost to reach a node and the estimated cost to reach the goal.
- **Dijkstra**: A classic algorithm that guarantees the shortest path in a weighted grid (works the same as A* without a heuristic).
- **Breadth-First Search (BFS)**: Explores all possible paths one step at a time, ensuring the shortest path in unweighted grids.
- **Depth-First Search (DFS)**: Explores as far as possible along each branch before backtracking. Does not guarantee the shortest path.
## Prerequisites
- Python 3.x
- Pygame
## Installation
1. Clone the repository:
```bash
git clone https://github.com/sahil352005/Pathfinding-Simulation.git
```
2. Install Pygame:
```bash
pip install pygame
```
or
```bash
python -m pip install pygame-ce
```
4. Run the script:
```bash
python main.py
```
## Usage
1. **Set start and end points**: Use the left mouse button to place the start (orange) and end (turquoise) points.
2. **Create barriers**: Use the left mouse button to draw barriers (black) that the pathfinder cannot pass through.
3. **Run the algorithm**: Select an algorithm from the dropdown menu, then click the "Run" button to see the visualization.
4. **Reset the grid**: Click the "Reset" button to clear the grid and start a new simulation.
### Controls
- **Left Click**: Set the start, end, and barriers.
- **Right Click**: Reset grid cells.
- **'C' Key**: Clear the entire grid.
- **Run Button**: Execute the chosen algorithm.
- **Reset Button**: Reset the grid and simulation.
## Screenshots



## Known Issues
- The simulation may not reset entirely if run multiple times. This can be resolved by pressing the **Reset** button before starting a new algorithm run.
## Future Enhancements
- Add more pathfinding algorithms (e.g., Greedy Best-First Search).
- Allow diagonal movement between grid cells.
- Implement weighted grids with varying terrain costs.
---
## Contributors
- https://github.com/sahil352005
- https://github.com/Lonwwolf14
- https://github.com/Vedashree14