Skip to content

A C++17 + SFML reimplementation of the A* pathfinding visualization. Features real-time grid interaction, Manhattan heuristic, and smooth rendering via SFML.

abubakar-mughal97/astar_visualization-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧭 A* Pathfinding Visualization (C++ & SFML)

This project is a C++ visualization of the A pathfinding algorithm*, built using the SFML graphics library.
It is inspired by the popular Python + Pygame A* tutorial by Tech With Tim,
available here on YouTube 👉 A* Path Finding Algorithm Tutorial. This version recreates the same functionality in modern C++17, using SFML for graphics and CMake for building.


🖼️ Screenshot

Here’s a preview of the A* Pathfinding Visualization:

A* Pathfinding Demo

🚀 Features

  • Real-time A* pathfinding visualization
  • Interactive grid where you can:
    • Set a start point (orange)
    • Set an end point (turquoise)
    • Draw barriers (black) by holding the left mouse button
    • Erase spots using the right mouse button
    • Run the algorithm with the Space key
    • Reset the grid with the C key
  • Smooth rendering using SFML

🎨 Color Legend

Element Color Description
Start 🟧 Orange Starting node
End 🟦 Turquoise Goal node
Barrier ⬛ Black Walls that block the path
Open Set 🟩 Green Nodes being explored
Closed Set 🟥 Red Nodes already evaluated
Path 🟪 Purple Final shortest path
Grid Background ⚪ White Empty traversable cells

🕹️ Controls

Action Mouse / Key Description
Set Start Node Left-click on an empty cell The first left-click sets the start node (orange)
Set End Node Left-click on another empty cell The second left-click sets the end node (turquoise)
Draw Barriers Hold Left Mouse and drag Adds black barriers continuously
Erase Cells Hold Right Mouse and drag Removes barriers or nodes
Run A* Press Spacebar Starts the A* pathfinding algorithm
Reset Grid Press C Clears the grid and resets everything

🧠 Algorithm Overview

The A* (A-star) algorithm is an informed search algorithm that finds the shortest path between two points.
It uses a heuristic function to estimate the cost from the current node to the goal.
This project uses the Manhattan distance heuristic.

Clone the Repository

Build with CMake

  • mkdir build
  • cd build
  • cmake ..
  • make

Run the Program

  • ./astar

About

A C++17 + SFML reimplementation of the A* pathfinding visualization. Features real-time grid interaction, Manhattan heuristic, and smooth rendering via SFML.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published