Demo program for the Mazegen library https://github.com/aleksandrbazhin/mazegen.
Mazegen is a maze generation library based on Bob Nystrom's approach, decribed here https://journal.stuffwithstuff.com/2014/12/21/rooms-and-mazes/
Binaries for Windows can be found on itch.io: https://aleksandrbazhin.itch.io/mazegen-maze-generator
Build system is CMake. All dependcies except SFML are used as git submodules.
SFML has to be installed somwhere in your system. It can be done with your system package manager or by adding to CMakeLists.txt
a line
set(SFML_DIR "{path to SFML on your system}/lib/cmake/SFML")
before the line
find_package(SFML ...
Theese are ImGui
, ImGui-SFML
, and mazegen
. Run
git submodule update --init --remote
mkdir build && cd build
cmake ..
cmake --build .
Should produce mazegen-sfml
executable in the build/
directory.
Refer to https://github.com/aleksandrbazhin/mazegen readme for more details on the algorithm.
The algorithm in short:
- Throws rooms randomly
Room place attempts
times. If the room overlaps others it is skipped`. - Grows the maze by random walk, wiggling with a
wiggle chance
, from every point. Unlike the original it has user-definedconstraints
which are first to be used as growth starting points. - Connects rooms to all the adjacent halls by the doors once. Each hall region is connected at least once.
- If the room is connected to an already connected region, the door is removed with
1.0f - extra connection chance
. Unlike the original, there is no flood fill to test for connectivity, instead union-find is used for maze regions. - Deadends are removed with
1.0f - deadend chance
. Ifdeadend chance
is 0, the maze just connects all the constraints and the rooms without any blind halls. - Deadends adjacent to the rooms are connected with
reconnect deadends chance
. This step is not in the original, but leads to a more natural looking maze - who would build a hall close to the room and not build a door?
- Export generate maze as a texture or json
- Render doors and constrained points
- Fine controls for ImGui slider