npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@sbj42/maze-generator-core

v0.1.4

Published

Core library for maze generator algorithms

Downloads

19

Readme

maze-generator-support

Support library for maze generator algorithms

This library supplies support classes for the @sbj42/maze-generator library, and the various maze algorithm plugins designed to work with it.

directions

A collection of cardinal direction utilities.

var dirs = require('@sbj42/maze-generator-support').directions;

dirs.NORTH / dirs.EAST / dirs.SOUTH / dirs.WEST

Constants representing the cardinal directions.

dirs.ALL

An array containing all the cardinal direction constants.

dirs.opposite(dir)

Returns the opposite of the direction given.

GridMask

A rectangular grid of boolean values, useful for marking visited cells in a maze.

var GridMask = require('@sbj42/maze-generator-support').GridMask;

new GridMask(width, height, options)

Creates a new GridMask. By default the interior cells are initialized to false, and exterior cells will return false. The (optional) options argument can be used to change that behavior:

  • options.interior: (optional) The boolean value to which interior cells are initialized.
  • options.exterior: (optional) The boolean value which will be returned for exterior cells.

GridMask.width() / GridMask.height()

Returns the width or height of the GridMask.

GridMask.get(x, y)

Returns the boolean value for the given cell. For cells outside the rectangular bounds, this returns false, or the value of options.exterior if given in the construtor.

GridMask.set(x, y, value)

Sets the boolean value for the given cell. Throws an error for cells outside the rectangular bounds.

Maze

A rectangular grid of cells, each of which may have passages in one or more of the four cardinal directions.

var Maze = require('@sbj42/maze-generator-support').Maze;

new Maze(width, height)

Creates a new Maze. The cells are all initialized to have no passages in any direction (or put another way, they have walls in all four directions).

maze.width() / maze.height()

Return the width and height of the maze.

maze.cell(x, y)

Returns a Cell object for the cell at the given position. For coordinates outside the rectangular bounds, this returns a Cell object with no passages.

maze.getPassage(x, y, dir)

Returns whether there is a passage at the given cell in the given direction. Returns false for coordinates outside the rectangular bounds, or for directions that would lead to a cell outside the bounds.

maze.setPassage(x, y, dir, value)

Sets whether there is a passage at the given cell in the given direction. Throws an error for coordinates outside the rectangular bounds, or for directions that would lead to a cell outside the bounds. This always adds the corresponding passage in the neighboring cell, so that the two cells have passages leading to each other.

Cell

An object representing a cell in a maze. There is no exported constructor, you have to get cell objects by calling maze.cell(x, y).

cell.north() / cell.east() / cell.south() / cell.west()

These boolean properties indicate whether the cell has a passage in each of the cardinal directions. If the property is true, then there is a passage in that direction. false indicates a wall.