Coder Social home page Coder Social logo

ellerjs's Introduction

ellerjs

tests npm

A JavaScript implementation of Eller's maze generation algoritm. this algorithm creates mazes that have a path between any two cells.

Rendered example

maze.png

Installation

npm i ellerjs

Usage

const eller = require('ellerjs');
const maze = eller(15, 15);

Maze is two-dimensional array representing rows and cells. Cell structure:

interface Cell {
  top: boolean; // true if cell has a wall in this direction, false if not
  bottom: boolean;
  left: boolean;
  right: boolean;
}

ellerjs's People

Contributors

ihorbeliasnyk avatar giancarl021 avatar

Stargazers

 avatar Trevor Blades avatar

Watchers

 avatar

Forkers

giancarl021

ellerjs's Issues

The lines below the first do not have a top property

I found a probable undesired behavior while running the package:

Steps to reproduce:

Run the following JavaScript code with the package installed:

const eller = require('ellerjs');

const maze = eller(2, 2);

console.log(JSON.stringify(maze, null, 2));

Current result:

[
  [
    {
      "top": true,
      "bottom": false,
      "left": true,
      "right": true,
      "_set": 1
    },
    {
      "top": true,
      "bottom": false,
      "left": true,
      "right": true,
      "_set": 2
    }
  ],
  [
    {
      "_set": 1,
      "right": false,
      "left": true,
      "bottom": true
    },
    {
      "_set": 1,
      "right": true,
      "left": false,
      "bottom": true
    }
  ]
]

Expected result:

[
  [
    {
      "top": "true|false",
      "bottom": false,
      "left": true,
      "right": true
    },
    {
      "top": "true|false",
      "bottom": false,
      "left": true,
      "right": true
    }
  ],
  [
    {
      "top": "true|false",
      "right": false,
      "left": true,
      "bottom": true
    },
    {
      "top": "true|false",
      "right": true,
      "left": false,
      "bottom": true
    }
  ]
]

As mentioned in the title, the top property of the cells is not present in the second line, and this is concisely the case for larger mazes. And the internal _set property can be found in the output generated, being shadowed by the type defined in index.d.ts.

Thank you in advance!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.