Maze Generator is an application that allows generating, visualizing, and solving mazes using different algorithms. The project includes support for loading mazes from files, generating new mazes with specific seeds, and saving generated mazes for later use.
- Maze generation using the Depth-First Search (DFS) algorithm.
- Maze visualization with SDL2.
- Loading mazes from
.labformat files. - Saving generated mazes to files.
- Support for setting specific seeds for reproducible maze generation.
- C++20: Main programming language.
- SDL2: Library for graphical maze visualization.
- CMake: Build system for compiling the project.
- STL: Extensive use of C++ Standard Library (e.g.,
std::vector,std::optional, etc.).
Ensure the following packages are installed on your system:
-
SDL2:
- On Debian/Ubuntu-based systems:
sudo apt update sudo apt install libsdl2-dev
- On Fedora-based systems:
sudo dnf install SDL2-devel
- On Debian/Ubuntu-based systems:
-
C++20-compatible compiler:
- GCC 10 or later:
sudo apt install g++
- Or Clang 10 or later:
sudo apt install clang
- GCC 10 or later:
-
CMake:
- On Debian/Ubuntu-based systems:
sudo apt install cmake
- On Debian/Ubuntu-based systems:
-
Clone this repository:
git clone https://github.com/your-username/maze-generator.git cd maze-generator -
Compile the project using the provided Makefile:
make
-
The executable will be generated in the
bindirectory.
The program supports the following command-line options:
-f [file]: Loads a maze from a.labfile. If no file is specified, the generated maze is saved to a new file.-s <seed>: Sets a specific seed for maze generation.-v: Enables visualization of the generated or loaded maze.
- Load a maze from a file:
./bin/maze -f maze.lab
- Generate a maze and save it to a new file:
./bin/maze -f
- Generate a maze with a specific seed and save it:
./bin/maze -f -s 12345
- Visualize a generated maze:
./bin/maze -v
.lab files follow this structure:
- First line: Maze width.
- Second line: Maze height.
- Remaining lines: Matrix representation of the maze, where each cell contains a number representing the walls.
Example:
10
10
11 9 5 3 9 1 5 5 5 3
10 10 11 10 10 14 9 5 3 14
12 6 8 6 8 5 4 7 12 3
...
Maze Generator is an educational and practical tool for exploring maze generation and solving algorithms. It uses the DFS algorithm to generate mazes and allows real-time visualization through SDL2. The project also supports saving and loading mazes, making it ideal for reproducible experiments and maze storage.