https://github.com/royaltm/js-labyrinth
The labyrinth generator
https://github.com/royaltm/js-labyrinth
labyrinth
Last synced: 12 months ago
JSON representation
The labyrinth generator
- Host: GitHub
- URL: https://github.com/royaltm/js-labyrinth
- Owner: royaltm
- License: unlicense
- Created: 2016-05-04T09:24:47.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-13T08:29:39.000Z (over 9 years ago)
- Last Synced: 2025-03-13T07:13:39.936Z (over 1 year ago)
- Topics: labyrinth
- Language: JavaScript
- Size: 21.5 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Labyrinth
=========
This library creates a true labyrinth using low-memory, cpu-intensive hunt'n'seek algorythm.
Program
-------
### Install
```
npm i -g royaltm/js-labyrinth
```
### Create
```
$ labyrinth
┏━━━━━━━┳━━━━━━━━━┳━┓
┃ ╺━┳━╸ ┃ ┏━━━━━┓ ╹ ┃
┣━━━┫ ╺━┻━┛ ┏━╸ ┃ ╺━┫
┃ ╻ ┗━━━━━┳━┛ ┏━┻━┓ ┃
┃ ┃ ┏━╸ ╻ ┃ ╻ ┃ ╻ ╹ ┃
┃ ┗━┫ ╺━┻━┛ ┗━┫ ┗━━━┫
┣━╸ ┣━╸ ┏━━━┓ ╹ ┏━━━┫
┃ ┏━┛ ┏━┻━┓ ┗━┳━┛ ╻ ┃
┃ ┗━┓ ┃ ╻ ┃ ╻ ╹ ┏━┫ ┃
┃ ╻ ┃ ╹ ┃ ┗━┻━╸ ┃ ╹ ┃
┗━┻━┻━━━┻━━━━━━━┻━━━┛
$ labyrinth 40 5
┏━━━━━┳━┳━━━━━━━━━┳━━━━━┳━━━┳━━━━━┳━━━━━┳━━━━━┳━┳━━━━━┳━━━━━━━━━━━━━━━┳━━━━━┳━━━┓
┃ ┏━╸ ┃ ┃ ╺━┓ ╺━┳━┛ ┏━┓ ╹ ╺━┫ ╺━┓ ╹ ┏━╸ ┃ ╺━┓ ┃ ┣━━━┓ ╹ ┏━━━━━━━┳━━━┓ ┗━━━┓ ╹ ╻ ┃
┃ ┣━━━┛ ┃ ╻ ┣━╸ ┃ ╺━┫ ┗━━━┓ ╹ ┏━┻━┓ ┣━━━┻━┓ ┃ ╹ ┃ ╻ ┗━┳━┫ ┏━━━╸ ┃ ╺━┻━━━┓ ┃ ╺━┫ ┃
┃ ╹ ╻ ╺━╋━┛ ┃ ╺━┫ ╻ ╹ ┏━┓ ┗━┳━┛ ╻ ╹ ┃ ╻ ╻ ┃ ┗━━━┫ ┗━┓ ╹ ┃ ┃ ╺━━━┻━━━┳━╸ ┃ ┣━╸ ┃ ┃
┣━━━┛ ╻ ╹ ╺━┻━┓ ╹ ┣━╸ ┃ ┗━╸ ┃ ╺━┻━━━┛ ┃ ┗━┛ ╺━┓ ╹ ╻ ┗━┓ ╹ ┃ ╺━━━┓ ╺━┛ ╻ ╹ ╹ ┏━┛ ┃
┗━━━━━┻━━━━━━━┻━━━┻━━━┻━━━━━┻━━━━━━━━━┻━━━━━━━┻━━━┻━━━┻━━━┻━━━━━┻━━━━━┻━━━━━┻━━━┛
```
Library
-------
Add to `package.json`:
```
"dependencies": {
"labyrinth": "royaltm/js-labyrinth"
}
```
```js
const {Wall, Direction} = require('labyrinth');
var wall = new Wall(20, 20);
wall.carve();
wall.print();
wall.open(0, 10, Direction.Up);
assert.equal(true, wall.isOpen(0, 10, Direction.Up));
wall.close(0, 10, Direction.Up);
assert.equal(false, wall.isOpen(0, 10, Direction.Up));
```