Skip to content

Home

This project provides set of utilities to generate, render, and other kind of stuff with mazes. Following are some mazes generated:

Usage

As mentioned early, these are just some set of utilizes which means that they can be hacked to do anything you like. The typical flow of generating a maze looks something as following:

Javascript

First, you need to install the mazes101 package using npm, yarn or alternatively you can also load umd modules from CDN:

npm i mazes101 --save
yarn add mazes101
<!--
    DON'T FORGET to replace x.x.x we appropriate version
    Check all the release here: https://github.com/nmanumr/mazes101/releases
-->
<script src="https://cdn.jsdelivr.net/npm/mazes101@x.x.x/index.umd.js"></script>
<script>
// here mazes101 is available in global scope
</script>

Then, the package can be used to generate the mazes as following:

1
2
3
4
5
6
7
import * as Rectangular from 'mazes101/boards/rectangular';
import {generate} from 'mazes101/generators/backtrack';
import {render} from 'mazes101/renderers/rectangularSvg';

let board = Rectangular.newBoard({height: 20, width: 20});
board = generate(board, Rectangular);
const svgString = render(board);

Note

The generate method returns a new board instead of altering the provided board so, it is important to assign that board somewhere. This is true for all the functions in Mazes101, they don't have side effects instead they return the changed value.

Deno

The deno package is not yet published to deno.land/x but you can use import_map.json file to map mazes101 package name to github.

import mazes101 from 'mazes101';
{
    "imports": {
        "mazes101/": "https://raw.githubusercontent.com/nmanumr/mazes101/deno/"
    }
}

To run the script use:

deno run --import-map=import_map.json index.ts

Status

The project is still under development and therefore contributions are welcomed here is the Status of the project:

  • Boards
    • Rectangular Board
    • Weave Board
    • Circular Board
    • Trinagular Board
    • Hexagonal Board
  • Generators
    • Aldous Broder
    • Backtrack
    • Eller
    • Kruskal
    • Prim
    • Sidewinder
    • Wilson
  • Renderers
    • SVG
    • Canvas

I'm also thinking to port the code base to other languages, current Python & Dart are in my wishlist so any contributions on porting are also welcomed.