node package manager



maze generator core

Version Coverage Status Version


You must use npm 2.7.0 or higher because of the scoped package name.

$ npm init
$ npm install @mitchallen/maze-generator-core --save


var cgFactory = require("@mitchallen/connection-grid-square"),
    mazeCore = require("@mitchallen/maze-generator-core");

spec = spec || {};

let _x = spec.x || 5;
let _y = spec.y || 6;

let _gridSpec = {
    x: _x,
    y: _y

var _connectionGrid = cgFactory.create(_gridSpec);
if(!_connectionGrid) {
    return null;

var maze = mazeCore.create( {
    grid: _connectionGrid,


Browser Usage

<!DOCTYPE html>
    <meta charset="utf-8">
    <title>Maze Generator Core Example</title>
    <meta name="description" content="Maze Generator Core Example">
    <!-- either cdn should work -->
    <script src=""></script>
    <script src=""></script>
    <script src=""></script>
      var cgFactory = window.MitchAllen.ConnectionGridSquare;
      var xSize = 10, ySize = 5;
      var cGrid = cgFactory.create( { x: xSize, y: ySize } );
      var factory = window.MitchAllen.MazeGeneratorCore;
      var sm = factory.create({
        grid: cGrid,
    <h1>Maze Generator Core Example</h1>
    <p>See JavaScript developer console for output.</p>



Maze Generator Core generated by create


A factory for generating maze generator core objects



Connection Grid Core

maze-generator-core ⇐ @mitchallen/connection-grid-core

Maze Generator Core generated by create

Extends: @mitchallen/connection-grid-core


Method called after generate generates a maze. This should be overriden by base class. The spec parameter will be passed on to this method after the maze has been generated. The derived method should parse spec for needed values.

Kind: instance method of maze-generator-core

Param Type Description
spec Object Named parameters for method

Example (possible usage)

// A derived object would have an afterGenerate method that parses 
let spec = {
   open: [
     { border: "N", list: [ 0, 2 ] },
     { border: "S", list: [ 3 ] }

maze-generator-core.generate(options) ⇒ boolean

Generators a maze

Kind: instance method of maze-generator-core

Param Type Description
options Object Named parameters for generating a maze
options.mask Array An array of cells to mask off from maze generation Array An array of objects designation what borders to open after generation
opions.start Object An object containing the x and y parameter of a cell to start maze generation from.

Example (generate)


Example (mask)

let spec = {
   mask: [
     { c: 2, r: 3 },
     { c: 2, r: 4 }

Example (start and mask)

let spec = {
   start: { c: 3, r: 3 },
   mask: [
     { c: 0, r: 0 },
     { c: 0, r: 1 },
     { c: 1, r: 0 },
     { c: 1, r: 1 }


A factory for generating maze generator core objects

maze-generator-core-factory.create(options) ⇒ maze-generator-core

Factory method that returns a maze generator core object. It takes one spec parameter that must be an object with named parameters.

Kind: static method of maze-generator-core-factory

Param Type Description
options Object Named parameters for generating a maze generator core
options.grid grid Grid based on @mitchallen/connection-grid-core

Example (Creating a maze-generator-core)

var cgFactory = require("@mitchallen/connection-grid-square"),
    mazeCore = require("@mitchallen/maze-generator-core"),
    connectionGrid = cgFactory.create( { x: 5, y: 6 } );
    maze = mazeCore.create( {
         grid: connectionGrid,


Connection Grid Core

Kind: global external
See: @mitchallen/connection-grid-core


To test, go to the root folder and type (sans $):

$ npm test



In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Version History

Version 0.1.7

  • updated dependencies
  • updated client example

Version 0.1.6

  • changed openBorder to afterGenerate to make it more generic
  • integrated travis-ci and
  • changed license to MIT
  • updated test cases for 100% code coverage

Version 0.1.5

  • added openBorder placeholder method for derived classes
  • updated documentation

Version 0.1.4

  • refactored generate method

Version 0.1.3

  • updated browser example

Version 0.1.2

  • removed file that wasn't being used.

Version 0.1.1

  • updated browser example to log array

Version 0.1.0

  • initial release