Skip to content

A visualization of the A* pathfinding algorithm in C++ using SDL2.

License

Notifications You must be signed in to change notification settings

LucaFeggi/Pathfinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧭 A* pathfinder

A C++ implementation of the A* pathfinding algorithm, visualized using SDL2.


📖 Description

This project implements a visual simulation of the A* pathfinding algorithm over a circular 2D grid, rendered in real time using SDL2. The system represents a circular path using discrete Cartesian coordinates, enabling the A* algorithm to operate as it would on a standard 2D grid while maintaining the curvature of the path. This approach facilitates extending the algorithm to handle full circuits with arbitrary shapes, since the underlying computations are not tied to a specific coordinate system.


🚀 Features

  • Fully configurable parameters via config.h
  • Resizeable window

🎮 Controls

Key Action
Esc Quit the simulation

⚙️ Project structure

Pathfinder
│
├── src/
│   ├── config.h
│   ├── main.cpp
│   ├── app/	
│   │   ├── app.h / app.cpp
│   │   ├── input.h / input.cpp
│   │   └── window.h / window.cpp
│   ├── simulation/
│   │   └── a_star.h / a_star.cpp
│   └── renderer/
│   	  └── renderer.h / renderer.cpp
├── assets/
│   └── icon/
│       └── icon.bmp
├── externals/
│   └── SDL2-2.32.10/
├── CMakeLists.txt
├── LICENCE
└── README.md

🔨 Build Instructions

🪟 Windows (Visual Studio)

📝 Notes:

  • SDL2 is automatically setupped.
  1. Open cmd

  2. Clone this repository:

    git clone https://github.com/LucaFeggi/Pathfinder
  3. Enter the project root:

    cd Pathfinder
  4. Generate project files:

    cmake -B build -G "Visual Studio 17 2022"
  5. Build the project:

    cmake --build build --config Release
  6. Run the executable:

    build\Release\Pathfinder.exe

🐧 Linux (Ubuntu/Debian)

📝 Notes:

  • SDL2 must be installed on the system, if not already present.
  • Make sure you’re running under the X11 display server (not Wayland), as SDL2 currently requires it.
  1. Open cmd
  2. Download SDL2 (optional):
    sudo apt install libsdl2-dev
  3. Clone this repository:
    git clone https://github.com/LucaFeggi/Pathfinder
  4. Enter the project root:
    cd Pathfinder
  5. Generate build files:
    cmake -B build
  6. Compile the project:
    cmake --build build --config Release
  7. Run the executable:
    ./build/Pathfinder

💡 Project idea

The idea for this pathfinding implementation was inspired by an algorithmic challenge received as part of the Race Up assignment from Università degli Studi di Padova.

assignment

🏆 Final result

A snapshot of the visualization after running the A* algorithm on the circular grid ($K=128$, $H=24$). The highlighted path represents the shortest path found from start to end point.

snapshot

About

A visualization of the A* pathfinding algorithm in C++ using SDL2.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published