C++ application for generating, editing, and solving mazes with visual, step-by-step algorithm animation using SFML.
LabyrinthAlgorithms provides a modular architecture separated into core maze logic, generation algorithms, solvers, and a visual front-end built with SFML. It supports multiple maze-generation strategies (DFS, Kruskal, Prim), pathfinding solvers (BFS, Dijkstra, A*), and an interactive editor for manual maze creation.
β οΈ Platform Notice
This application has been developed and tested only on Windows.
While it may compile on Linux or macOS with minimal changes, cross-platform compatibility is not guaranteed at this time.
The stable-core branch contains the most reliable and well-tested parts of the project.
π If you are integrating or reusing this project,
stable-coreis the recommended dependency layer.
- Maze generation: DFS, Kruskal, Prim.
- Pathfinding: BFS, Dijkstra, A*.
- Interactive GUI (SFML): draw/edit mazes, set start/goal, visualize algorithm progress.
- Playback controls: slow / pause / fast / skip and adjustable animation delay.
- File persistence: save/load maze
.txtfiles and results.txtreports.
- C++ 17 compiler
- SFML 3.0.2
- CMake 3.10+ (recommended)
git clone https://github.com/Asymphia/LabyrinthAlgorithms.git
cd LabyrinthAlgorithmsInstall SFML via vcpkg or download binaries from the SFML website.
sudo apt-get update
sudo apt-get install libsfml-devbrew install sfmlCreate required folders (relative to the executable / build folder):
mkdir -p mazes
mkdir -p resultsThese folders are required at runtime β the FileManager expects ./mazes and ./results.
mkdir build && cd build
cmake ..
make
./LabyrinthAlgorithmsThe codebase is organized to separate the maze logic, generation/solving algorithms, and visualization.
- Cell β Represents a single grid unit (
WallorEmpty). - Maze β Grid container that manages cell states, bounds checking, resizing, and I/O.
All generators inherit from a MazeGenerator base and provide a history_ log for visualization playback.
- DFS (Depth-First Search) β long winding corridors, deeper recursion.
- Kruskal β forest-based merging using Union-Find for a perfect maze.
- Prim β grows the maze from a random start, producing a different branching structure.
Solvers compute the path between a Start and Goal cell:
- BFS β guaranteed shortest path for unweighted grids.
- Dijkstra β shortest path over weighted edges (if weights used).
- A* β optimizes using heuristic (Manhattan). Heuristic formula:
f(n) = g(n) + h(n).
Stroned in /mazes folder. Stored as text files with characters:
C= WallB= Empty Filenames generated automatically:maze_1.txt,maze_2.txt,β¦
CCCCCCCCCCC
CBCBBBBBBBC
CBCBCBCCCCC
CCCCCCCCCCC
Stored in /results folder. Contain run metadata and solver statistics.
The UI is implemented as a simple state machine inside the Simulation class. Typical workflow:
- Main Menu β choose to generate, manually draw, or load a file.
- Edit Maze β draw or erase walls with mouse.
- Select Points β first click sets Start (green), second sets Goal (red).
- Visualization β play the algorithm with animation and controls.
- Results β view and export statistics.
Feel free to open issues or pull requests for:
- Additional generation/solving algorithms.
- Improvements to the GUI and UX.
- Cross-platform installer scripts or packaging.