Skip to the content

Meikyuu迷宮

Generate seeded mazes and arrow puzzles, follow numbered levels, and play on flat grids or three-dimensional surfaces.

Meikyuu is the Japanese word 迷宮 for labyrinth. About the name

Contents

Reference · Mazes, arrows and mixed boards

Mazetype

A seeded flat maze with its cell graph, passages, doors, endpoints and optional keys.

Import it

import type { Maze } from "@johnmorrisdotca/meikyuu";

Definition

type Maze = {
    readonly recipe: MazeRecipe;
    readonly grid: Grid;
    readonly links: Links;
    readonly start: number;
    readonly goal: number;
    readonly entrance: Door | null;
    readonly exit: Door | null;
    readonly keys: readonly number[];
};

Members

NameTypeDescription
recipeMazeRecipe
gridGrid
linksLinks

Each cell's open neighbours.

startnumber

The cell the line starts in.

goalnumber

The cell the line must reach.

entranceDoor | null

The door the line comes in by, for enter-leave.

exitDoor | null

The door the line goes out by, for enter-leave, centre-out and keys.

keysreadonly number[]

The keys to collect, for keys.

Examples

import type { Maze, 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 value: Maze = maze;
console.log(value);
{
  recipe: {
    shape: 'square',
    w: 5,
    h: 5,
    algorithm: 'backtracker',
    mode: 'to-goal',
    seed: 42
  },
  grid: {
    shape: 'square',
    w: 5,
    h: 5,
    centres: [
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array]
    ],
    sides: [
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array]
    ],
    box: { x: 0, y: 0, w: 5, h: 5 },
    at: [Function: at],
    cells: 25,
    neighbours: [
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array], [Array], [Array],
      [Array]
    ]
  },
  links: [
    [ 1, 5 ],       [ 2, 0 ],
    [ 7, 3, 1 ],    [ 2, 4 ],
    [ 3 ],          [ 0, 6 ],
    [ 5, 11 ],      [ 8, 2 ],
    [ 9, 7 ],       [ 14, 8 ],
    [ 11 ],         [ 6, 12, 10 ],
    [ 11, 17, 13 ], [ 12 ],
    [ 19, 9 ],      [ 16 ],
    [ 15, 21 ],     [ 12 ],
    [ 23, 19 ],     [ 18, 24, 14 ],
    [ 21 ],         [ 16, 20, 22 ],
    [ 21, 23 ],     [ 22, 18 ],
    [ 19 ]
  ],
  start: 6,
  goal: 15,
  entrance: null,
  exit: null,
  keys: []
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/meikyuu 3.2.0.