originshift
v1.0.0
Published
Maze generation algorithm
Downloads
16
Readme
Origin Shift
Origin Shift is a package that implements a maze generator algorithm inspired by CaptainLuma.
Prerequisites
Before using Origin Shift, ensure you have the following:
- Node.js installed.
Installation
To install Origin Shift using npm, run:
npm install originshift --save
Advantages
- Guaranteed Paths: There is always a path from every point to any other.
- Dynamic Mazes: The maze can change dynamically, allowing you to interact with it in real-time.
Disadvantages
- Initial Configuration: The maze may require multiple steps to achieve a complex structure.
Constructor
The constructor takes one argument: the size of the maze (Size x Size). It initializes the maze with 5 * size steps, creating a simple starting configuration.
Methods
- step(): Advances the maze by one step, modifying its layout.
- generate(iterations): Advances the maze by a specified number of steps in one call.
- getArray(): Returns an array representation of the maze:
- -1 => Origin
- 0 => Up
- 1 => Right
- 2 => Down
- 3 => Left
Examples
const Maze = require('originshift');
let maze = new Maze(10); // Creates a 10x10 maze
console.log(maze.getArray()); // Displays the array representation of the maze