Program to solve a maze in c++ using BFS.
>>> The Maze has solution!:
·····█ █ █·········█ █
█·███·█ █ ███ ███ █·███████·███████ █ █
█···█Ω█ █ █ █ █···█ █Σ█ █ █ █
███·█ █ █ █ ███ █████·█ █ ███ ███ █ ███
█·█ █ █ █ █·····█ █ █ █ █
██ █·█████ █ █████·█████ ███████ █ ███ █
█·█ █ █ █···█···█ █ █ █
███·█ █ █ █ █·█·███·███████████ █████ █
█···█ █ █·█· █···█·····█ █ █ █
█·███ ███████·█·█████·█·███·█ ███ █ ███
█·█ █ █ █·····█·······█·█···█ █ █
██·█ █ █ █·█████████████·█·█████ █████ █
···█ █ █ █·█ ···█·····█ █ █ █
·███ █ █ █·███████ ███·███████·█ █ █ ███
·█ █···█···█ █···█ █·█ █ █
·███████████·█·█·███·█████ █ █·███████ █
·····█·····█···█·····█··· █ █·······█ █
███·█·███·███████████·█·███████████·█ █
█··· █·············█············· █
████████████████████████████████████████
You can generate your own maze using scripts/gen_maze.py with the following options:
usage: gen_maze.py [-h] FILE [HEIGHT] [WIDTH]
Generate a maze with a start and finish.
positional arguments:
FILE File to save the maze
HEIGHT Height of the maze
WIDTH Width of the maze
options:
-h, --help show this help message and exit
Or use a pre-generated one that is already in the repo. If you want to use another one with name other than data/out1.dat, make sure to alter the correspondent code in src/main.cpp.
// In main.cpp
maze::Maze maze("data/out1.dat"); //!< Change to desired fileMake sure you have cmake and a c++ compiler installed
In project root folder:
-
Source
CMakeLists.txtand createbuild/directory:cmake -S . -B build -
Compile the program:
cmake --build build -
The executable will be
build/maze. Run-it!./build/maze
- Get the
.datfile from config file and/or command line. - Show colors for visualizing in terminal.
- Animate the search process into a video.
© IMD/UFRN 2024.