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

MazeGametype

A MAZE BEING DRAWN, as pure functions: each takes a game and returns a new one (or the same one, when nothing changed), so a page, a server and a test play by the same rules.

A line starts at the start cell and runs through open passages, one cell to the next. A cell the line is on again cuts the line back to it, so drawing back shortens it and a line never crosses itself, and never enters a cell with a stone on it (stones.ts). A key is picked up by passing over it and stays picked up when the line is drawn back. The maze is solved when the line's end is on the goal and every key is picked up; after that the line is fixed until Undo or Restart.

A finger is a stroke: pressMaze begins one (on the start, on the line's end, or on any cell of the line, which cuts it back there), dragMaze follows it into each cell, liftMaze ends it and is what Undo undoes. A tap, where the page offers it, is tapMaze.

Import it

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

Definition

type MazeGame<M extends MazeCore = Maze> = {
    readonly maze: M;
    readonly path: readonly number[];
    readonly collected: readonly number[];
    readonly solved: boolean;
    readonly drawing: boolean;
    readonly strokes: number;
    readonly stones: readonly number[];
    readonly rules: StoneRules | null;
    readonly undo: readonly {
        readonly path: readonly number[];
        readonly collected: readonly number[];
        readonly solved: boolean;
        readonly stones: readonly number[];
    }[];
};

Members

NameTypeDescription
mazeM
pathreadonly number[]

The line, from the start; empty until it is begun.

collectedreadonly number[]

The keys picked up, in the order they were.

solvedboolean
drawingboolean

Whether a stroke is being drawn.

strokesnumber

How many strokes have been made, to count moves.

stonesreadonly number[]

The cells with a stone on them, in the order they were laid (see stones.ts); always empty in a game with no rules.

rulesStoneRules | null

What stones may be laid (StoneRules), or null for a game that has none.

undoreadonly { readonly path: readonly number[]; readonly collected: readonly number[]; readonly solved: boolean; readonly stones: readonly number[]; }[]

What each finished stroke (or each stone laid or taken up) started from, newest last, for Undo.

Examples

import type { MazeGame, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze, newMazeGame } from "@johnmorrisdotca/meikyuu";

const recipe: MazeRecipe = {shape:"square",w:5,h:5,algorithm:"backtracker",mode:"to-goal",seed:42};
const maze = buildMaze(recipe);
const game = newMazeGame(maze);
const value: MazeGame = game;
console.log(value);
{
  maze: {
    recipe: {
      shape: 'square',
      w: 5,
      h: 5,
      algorithm: 'backtracker',
      mode: 'to-goal',
      seed: 42
    },
    grid: {
      shape: 'square',
      w: 5,
      h: 5,
      centres: [Array],
      sides: [Array],
      box: [Object],
      at: [Function: at],
      cells: 25,
      neighbours: [Array]
    },
    links: [
      [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]
    ],
    start: 6,
    goal: 15,
    entrance: null,
    exit: null,
    keys: []
  },
  path: [],
  collected: [],
  solved: false,
  drawing: false,
  strokes: 0,
  undo: [],
  stones: [],
  rules: null
}

What it prints (run when this page was built)

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