A standalone visualisation of the A* pathfinding algorithm, built in C++ and rendered with SDL2. Designed to help developers, students, and game designers understand how A* works in real-time through interactive grid simulation.
- A Pathfinding Algorithm*: Efficiently finds the shortest path using a heuristic-based approach (
f(n) = g(n) + h(n)). - Interactive Visualisation: Real-time rendering of nodes, paths, and visited cells using SDL2.
- Custom Grid & Obstacles: Modify the environment by adding/removing obstacles on a 20x20 grid.
- Manhattan Heuristic: Estimates shortest paths in grid-based maps (perfect for 4-direction movement).
- Neighbour Node Calculation: Safely checks surrounding nodes while respecting map boundaries and obstacles.
- Easter Egg Trigger: A fun, hidden feature triggered when the player resets the simulation — includes an AI-generated voice.
- Modular Design: Easily adaptable for integration into simulation games, colony simulators, or AI navigation systems.
- C++11 (or later)
- SDL2 development libraries installed
- CMake (recommended for building)
# Clone the repository
git clone https://github.com/yourusername/a-star-pathfinding-visualiser.git
# Build using CMake
cd a-star-pathfinding-visualiser
mkdir build && cd build
cmake ..
make
# Run the program
./astar_visualiser| Action | Description |
|---|---|
| Left Click | Place the start and end nodes |
| Right Click | Add/remove obstacles |
| Enter/Return | Start the A* pathfinding algorithm |
| R Key | Reset the simulation (triggers easter egg) |
| ESC | Exit the application |
Including a LICENSE file clarifies how others may use, modify, and distribute your code. By choosing an open-source license such as MIT, you grant permission for use under defined terms while protecting your intellectual property and limiting liability.
This project is licensed under the MIT License. See LICENSE for full details.
a-star-pathfinding-visualiser/
├── astar/ # Core source code and assets
│ ├── astar.cpp # Main program entry point
│ ├── game.cpp # Handles simulation loop and input events
│ ├── game.h # Header for Game class and related methods
│ ├── grid.cpp # Logic for grid creation, obstacle placement, and node status
│ ├── grid.h # Grid structure definitions and constants
│ ├── pathfinding.cpp # Implementation of the A* pathfinding algorithm
│ ├── pathfinding.h # A* algorithm declarations and helper functions
│ ├── renderer.cpp # SDL2 rendering logic for nodes, grid, and path
│ ├── renderer.h # Renderer class definitions and SDL2 includes
│ ├── easteregg.wav # AI-generated audio clip played when reset is triggered
│ └── sound1.wav # Additional sound effect (e.g., on goal reached or path found)
│
├── x64/ # Output build folder
│ └── Debug/
│ └── astar.exe # Compiled executable for debug testing
│
├── astar.sln # Visual Studio Solution file to build and run the project
└── README.md # Project documentation
- Open List (Priority Queue): Stores nodes to explore, sorted by lowest f value.
- Closed List: Keeps track of already-visited nodes.
- Neighbour Checking: Checks left, right, up, and down directions.
- Heuristic Function: Uses Manhattan Distance to guide the search.
- Path Backtracking: Reconstructs the optimal path by following parent pointers from goal to start.
- NPC pathfinding simulation for use in games
- Variable terrain costs (e.g., grass, water, roads)
- Larger grids and map importing
- Multiple goal targets and patrol route support
- Pathfinding performance analysis tool
- GUI-based map editor for custom terrain
- Export path as JSON or image
- Mouse-hover node details in UI
- Daniel Cullinane – [email protected]
- GitHub: @dancull