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

MazeMeasuretype

HOW HARD A MAZE IS, measured from the maze alone (docs/MAZES.md says why each number is here). Everything is a whole number counted off the passages, so the same maze measures the same in every engine, and a level list ordered by effort stays ordered.

effort is an estimate, in cells drawn, of what a person does to solve it: the length of the way through, plus the length of the wrong turns taken (a person who meets a fork takes the wrong side half the time and walks to the end of it before turning back, so half of two times the depth of each wrong branch), plus two for every fork on the way (looking, and deciding), plus what collecting the keys adds. A big maze with a long way through costs more than a small one with many dead ends, as it takes longer to draw; two mazes of one size cost what their branching makes them.

Import it

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

Definition

type MazeMeasure = {
    cells: number;
    deadEnds: number;
    deadEndShare: number;
    junctions: number;
    river: number;
    solution: number;
    decisions: number;
    branches: number;
    longestBranch: number;
    wasted: number;
    detour: number;
    effort: number;
};

Members

NameTypeDescription
cellsnumber
deadEndsnumber

Cells with one passage.

deadEndSharenumber
junctionsnumber

Cells with three or more passages.

rivernumber

The share of cells with exactly two passages: a high river is a maze of long winding corridors.

solutionnumber

Cells on the way from the start to the goal, both included.

decisionsnumber

Places on the way where the line could have gone another way.

branchesnumber

Wrong branches that leave the way.

longestBranchnumber

The length of the longest of them, to its end.

wastednumber

The lengths of all the wrong branches, added up.

detournumber

What collecting the keys costs: there and back to each, off the way.

effortnumber

Examples

import type { MazeMeasure, MazeRecipe } from "@johnmorrisdotca/meikyuu";
import { buildMaze, measureMaze } 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: MazeMeasure = measureMaze(maze);
console.log(value);
{
  cells: 25,
  deadEnds: 7,
  deadEndShare: 0.28,
  junctions: 5,
  river: 0.52,
  solution: 16,
  decisions: 4,
  branches: 4,
  longestBranch: 3,
  wasted: 7,
  detour: 0,
  effort: 31
}

What it prints (run when this page was built)

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