Prim’s (True)

In a nutshell:

First, assign every cell a random weight, and initialize a set with an arbitrary cell. Choose the cell with the greatest weight from the set. If it has no unvisited neighbors, remove it from the set. Otherwise, choose one of the cell’s unvisited neighbors, link the two together, and add the neighbor to the set. Repeat until the set is empty.

images/appendix-prims-true.png
Typical features:

Many, many dead ends per maze, with relatively shorter paths in general. Texture-wise, the mazes have a “jigsaw puzzle” appearance.

More information:

True Prim’s Algorithm.

Get Mazes for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.