Flexible perfect maze generator
This module generates "perfect mazes" (i.e. no loops) by connecting "nodes" from a given list.
Note that a "node" does not necessarily have to be a regular grid cell - it can be of any shape or size!
npm install maze
See test.js
for an extensive example. You could also clone this repository and run the script locally if you'd like to run the maze generator on your machine.
Maps each node in nodes
to a list of connections and stores the resulting Map
in maze
.
nodes
: A list of nodes to connectadjacent
: A function of the formadjacent(a, b)
which determines if nodea
and nodeb
can be connectedchoose
: A function of the formchoose(array)
which chooses a random item fromarray