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
| Name | Type | Description |
|---|---|---|
cells | number | |
deadEnds | number | Cells with one passage. |
deadEndShare | number | |
junctions | number | Cells with three or more passages. |
river | number | The share of cells with exactly two passages: a high |
solution | number | Cells on the way from the start to the goal, both included. |
decisions | number | Places on the way where the line could have gone another way. |
branches | number | Wrong branches that leave the way. |
longestBranch | number | The length of the longest of them, to its end. |
wasted | number | The lengths of all the wrong branches, added up. |
detour | number | What collecting the keys costs: there and back to each, off the way. |
effort | number |
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)