Skip to content

A C++ terminal application that implements Wilson’s Algorithm for generating perfect mazes — mazes with exactly one unique path between any two cells.

Notifications You must be signed in to change notification settings

theta205/wilsons-algo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Wilson’s Algorithm Maze Generator

A C++ terminal application that implements Wilson’s Algorithm for generating perfect mazes — mazes with exactly one unique path between any two cells.


How Wilson’s Algorithm Works

  1. Start with a grid of walls (#).
  2. Choose one random cell and mark it as part of the maze.
  3. Pick another random cell not in the maze.
  4. Perform a random walk until the walk touches the existing maze.
    • If a loop forms during the walk, erase it (loop erasure).
  5. Convert the walk’s cells into maze passages (' ').
  6. Repeat until every cell is part of the maze or a "wall".

This produces a perfect maze — every cell is reachable, and no cycles exist.


Valid cmds

  1. make (builds executable)
  2. make clean (removes the executable)
  3. make run (runs executable)

File Structure

Wilson_Algo/
├── main.cpp        # Core implementation of Wilson's algorithm
├── Makefile        # Build commands
├── README.md       # Project documentation
└── .gitignore      # Ignore build artifacts

DEMO

ScreenRecording2025-10-15at8 32 54PM-ezgif com-speed (3)

About

A C++ terminal application that implements Wilson’s Algorithm for generating perfect mazes — mazes with exactly one unique path between any two cells.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published