generate-maze
Maze generator using a JavaScript implementation of Eller's Algorithm,
as described here: http://www.neocomputer.org/projects/eller.html
This algorithm creates 'perfect' mazes, which guarantees a single path
between any two cells, such as:
+---+---+---+---+---+---+---+
| | | |
+---+ +---+ + + + +
| | | | | |
+ + + + + + + +
| | | | | | |
+ +---+ + +---+---+ +
| | | | | | | |
+ + + + + + + +
| | | | | |
+ +---+ +---+ +---+---+
| | | | | |
+ + + + +---+ + +
| | |
+---+---+---+---+---+---+---+
Another Web example
Note: This library does not create ASCII-art or other text visualizations.
That part is up to you.
This library generates a two-dimensional array of maze cells, each with the following properties:
{
x: 4,
y: 7,
top: false,
left: false,
bottom: true,
right: true,
set: 5
}
Installation
npm install generate-maze
Usage
Example assumes you are using a module system such as node, Webpack or Browserify.
const generator = require('generate-maze');
const maze = generator(4);
const maze = generator(8, 4);
const maze = generator(8, 4, false);
const maze = generator(8, 4, true, 123456);
_Note: the maze is an array of rows, so to access individual cells by their x/y
positions, you need to specify the row first. For example:
maze[y][x]