Lazy Eller
This package implements the Eller maze algorithm to generate potentially-infinite 2D mazes. The maze generator is implemented as an iterator over lazily-generated rows.
The package exports a single EllerMaze
class with the following interface:
new EllerMaze(opts: EllerArgs): EllerMaze
Creates a new maze generator, which implements the IterableIterator interface.em.next(final?: boolean): IteratorResult<Cell[]>
Returns the next row of the maze, as an array of cells. Iftrue
is passed in, the returned row will be the final row of a finite maze.EllerMaze.toASCII(row: Cell[]): string
Produces an ASCII-art representation of a maze row for debugging purposes.
The EllerArgs
type is defined as follows:
;
Meanwhile, Cell
objects have the following form:
;
which implements a cell graph. Null values indicate the presence of walls. Proper mazes are represented by spanning trees over the graph of cells.