Reference · Mazes, arrows and mixed boards
CellGraphtype
What a generator reads of a grid: how many cells there are and which are beside which. A Grid is one, and so is the surface of a solid
(@johnmorrisdotca/meikyuu/3d); shape, w and h are only for Eller's algorithm, which needs rows and so makes square mazes.
Import it
import type { CellGraph } from "@johnmorrisdotca/meikyuu";
Definition
type CellGraph = Pick<Grid, "cells" | "neighbours" | "w" | "h"> & {
readonly shape: string;
};
Members
| Name | Type | Description |
|---|---|---|
w | number | The two numbers the shape was asked for (columns and rows; rings; a radius). |
cells | number | |
neighbours | readonly (readonly number[])[] | Each cell's neighbours across a side that is not the shape's edge. |
h | number | |
shape | string |
Examples
import type { CellGraph, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze } from "@johnmorrisdotca/meikyuu";
const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const grid = maze.grid;
const value: CellGraph = grid;
console.log(value);{
shape: 'square',
w: 5,
h: 5,
centres: [
[ 0.5, 0.5 ], [ 1.5, 0.5 ],
[ 2.5, 0.5 ], [ 3.5, 0.5 ],
[ 4.5, 0.5 ], [ 0.5, 1.5 ],
[ 1.5, 1.5 ], [ 2.5, 1.5 ],
[ 3.5, 1.5 ], [ 4.5, 1.5 ],
[ 0.5, 2.5 ], [ 1.5, 2.5 ],
[ 2.5, 2.5 ], [ 3.5, 2.5 ],
[ 4.5, 2.5 ], [ 0.5, 3.5 ],
[ 1.5, 3.5 ], [ 2.5, 3.5 ],
[ 3.5, 3.5 ], [ 4.5, 3.5 ],
[ 0.5, 4.5 ], [ 1.5, 4.5 ],
[ 2.5, 4.5 ], [ 3.5, 4.5 ],
[ 4.5, 4.5 ]
],
sides: [
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ],
[ [Object], [Object], [Object], [Object] ]
],
box: { x: 0, y: 0, w: 5, h: 5 },
at: [Function: at],
cells: 25,
neighbours: [
[ 1, 5 ], [ 2, 6, 0 ],
[ 3, 7, 1 ], [ 4, 8, 2 ],
[ 9, 3 ], [ 0, 6, 10 ],
[ 1, 7, 11, 5 ], [ 2, 8, 12, 6 ],
[ 3, 9, 13, 7 ], [ 4, 14, 8 ],
[ 5, 11, 15 ], [ 6, 12, 16, 10 ],
[ 7, 13, 17, 11 ], [ 8, 14, 18, 12 ],
[ 9, 19, 13 ], [ 10, 16, 20 ],
[ 11, 17, 21, 15 ], [ 12, 18, 22, 16 ],
[ 13, 19, 23, 17 ], [ 14, 24, 18 ],
[ 15, 21 ], [ 16, 22, 20 ],
[ 17, 23, 21 ], [ 18, 24, 22 ],
[ 19, 23 ]
]
}What it prints (run when this page was built)