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

trailz

v0.0.7

Published

A library for generating mazes

Downloads

4

Readme

trailz

A library for generating mazes

build tslint code style Test Runner NPM Coverage Status

This library is based on the algorithms from the book Mazes for Programmers: Code Your Own Twisty Little Passages, by Jamis Buck

Requirements

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as an application dependency:

$ yarn add trailz

To install as a global dependency for CLI use (options below):

$ yarn global add trailz

To build the app and run all tests:

$ yarn run all

Overview

To use the library create an instance of the Maze class with the size requirements and algorithm type. It will automatically generate the maze and save it within a grid. The contents of the maze can be retrieved by using the .string or .repr properties to get the contents. The .string will give an ASCII string representation of the maze. The .repr method will return a two dimensional array that contains the representation of that cell. This representation is 1 of 16 possible representations for a cell (for drawing purposes).

+---+---+---+---+---+---+---+---+---+---+
|                                       |
+---+   +   +   +   +   +   +---+---+   +
|       |   |   |   |   |   |           |
+---+---+   +   +   +---+---+---+---+   +
|           |   |   |                   |
+   +---+---+   +---+   +---+   +---+   +
|   |           |       |       |       |
+---+---+---+---+   +   +   +   +---+   +
|                   |   |   |   |       |
+---+   +   +   +---+---+   +   +   +   +
|       |   |   |           |   |   |   |
+---+---+   +   +   +   +---+---+---+   +
|           |   |   |   |               |
+   +---+   +   +---+   +---+   +---+   +
|   |       |   |       |       |       |
+   +   +---+---+   +---+   +---+---+   +
|   |   |           |       |           |
+   +   +   +---+   +---+---+   +   +   +
|   |   |   |       |           |   |   |
+---+---+---+---+---+---+---+---+---+---+

 11,  8,  8,  8,  8,  8,  8, 10, 10, 12
 11,  6,  5,  5,  5,  7,  7, 11, 10,  4
  9, 10,  6,  5,  7,  9, 10,  8, 10,  4
  7, 11, 10,  6,  9,  4,  9,  4, 11,  4
 11,  8,  8,  8,  6,  7,  5,  5,  9,  4
 11,  6,  5,  5,  9,  8,  6,  7,  7,  5
  9, 10,  4,  5,  7,  5, 11,  8, 10,  4
  5,  9,  6,  7,  9,  6,  9,  6, 11,  4
  5,  5,  9, 10,  4, 11,  6,  9,  8,  4
  7,  7,  7, 11,  6, 11, 10,  6,  7,  7

SREPR Values

Usage

import {AlgorithmType, Maze} from 'trailz';

const maze = new Maze(10, 10, AlgorithmType.BinaryTree);
console.log(maze.string);

This will create a new instance of a maze using the BinaryTree algorithm. A new instance of the maze can be rebuilt without creating a new instance with:

maze.rebuild(AlgorithmType.BinaryTree);

This will reset the grid and reapply the BinaryTree algorithm to the grid. The grid can be resized and rebuilt too.

maze.resize(5, 5)

This will resize the grid to a 5x5 maze and reapply the algorithm.

CLI

The command line interface allows one to create mazes and print their contents to a text file.

$ trailz -r 25 -c 25 -a Sidewinder --verbose -o maze.txt

This will create a 25x25 maze using the Sidewinder algorithm. The contents will be printed to the terminal and also written to a file named maze.txt (the default).

Arguments
  • -r|--rows {#} - the number of rows to create in the maze. The default is 10.
  • -c|--cols {#} - the number of columns to create in the maze. The default is 10.
  • -a|--algorithm {name} - the string name of the algorithm to use when generating the maze (see the list below). The current default is the BinaryTree algorithm.
  • -v|--verbose - will dump the contents of the generated maze to stdout. Not shown by default.
  • -o|--output {filename} - where to dump the contents of the maze (text file). The file maze.txt is used by default and will be overwritten on successive runs.

API

Algorithms