
AStarPathfindingSFML
A from-scratch A* pathfinding visualizer in C++ with SFML: a 100×100 grid, mouse-painted walls, eight-directional Euclidean search, and live open/closed-set visualization.
AStarPathfindingSFML is a from-scratch A* pathfinding visualizer written in C++ with SFML. It renders a 100×100 grid of tiles, lets the user paint walls with the mouse, pick a start and a destination, and then runs a classic A* search (eight-directional, Euclidean heuristic) to find and draw the resulting path on the grid.
The open and closed sets are visualized live via tile colors, so the algorithm's expansion is visible. The architecture is intentionally minimal: one App class owns the SFML window and a Map, the Map owns the tile grid plus an AStar searcher, and the search mutates the same Tile array used for rendering — there is no separate search-domain structure.
A* runs on the shared grid: a std::set serves as the priority queue (sorted by f), the loop pops the lowest-f cell, marks it closed, and expands its 8 neighbors. reconstructPath walks parentCoords from the destination back to the start, marking each cell as part of the path. Colors are driven through shared sf::Vertex pointers cached per tile, so recoloring is just writing through the vertex array.
Key features
- From-scratch A* in C++/SFML over a 100×100 tile grid.
- Eight-directional expansion with a Euclidean heuristic.
- Mouse painting: left = wall, right = start, middle = destination; C = run search.
- Live open/closed-set visualization via tile colors.
- Single sf::VertexArray of quads (one per tile); colors driven through cached vertex pointers.
- std::set priority queue; reconstructPath walks parentCoords back to the start.
- CMake build; SFML fetched through the build system (no manual install).