Reference · Mazes, arrows and mixed boards
isPerfectfunction
Whether the passages are a spanning tree of the grid: every cell reached, and exactly one way to each.
Import it
import { isPerfect } from "@johnmorrisdotca/meikyuu";
Definition
function isPerfect(grid: MazeCore["grid"], links: Links): boolean
Parameters
| Name | Type | Description |
|---|---|---|
grid | { readonly cells: number; readonly neighbours: readonly (readonly number[])[]; } | The valid native flat or surface cell graph. |
links | Links | Passage neighbour lists, one per cell. |
Returns
boolean
Whether the passages are a spanning tree of the grid: every cell reached, and exactly one way to each.
Examples
import type { MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze, isPerfect } 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;
console.log(isPerfect(grid,maze.links));trueWhat it prints (run when this page was built)