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

import { … } from "@johnmorrisdotca/meikyuu";

12.7 kB minified and gzipped, with everything it imports (measured with esbuild)

Meikyuu 迷宮, a maze game: the rules and the making, with no page needed.

Exports

NameKindWhat it is
ArrowtypeOne arrow: its cells from tail to head (indexes into the board, row by row), and the way its head points.
ARROW_HEARTSconstantThe hearts a puzzle starts with.
ARROW_SHAPESconstantThe pictures an arrow board can be: the whole square, or one of the shapes cut from it.
ARROW_STEPSconstantThe up, right, down and left row/column increments of arrow directions.
ArrowBoardtypeThe native arrow recipe, shape mask, arrow paths and locked flags.
ArrowDirectiontypeWhich way an arrow's head points: up, right, down, left.
ArrowGametypeAN ARROW PUZZLE BEING PLAYED, as pure functions.
ArrowMeasuretypeHow hard an arrow puzzle is: the arrows to clear, the rounds of unblocking they take, and how many are blocked at the start.
ArrowRecipetypeEverything that makes an arrow puzzle.
arrowRecipeCodefunctionA recipe as a short word, such as heart:15:6:77 or square:9x9:5:123:2 (the last number: how many are locked), and back.
ArrowShapetypeOne of the supported flat arrow-board masks.
arrowsLeftfunctionThe count of arrows still on the board.
ArrowTaptypeWhat a tap did.
autoTurnfunctionauto: turn a maze when that makes it bigger in the room there is.
belowfunctionA whole number in [0, n) from the stream.
blockedByfunctionThe arrows on the way out of id that are still on the board.
blockersOffunctionWhich arrows block others: for each arrow, the arrows whose cells lie on its way out.
boundaryCellsfunctionThe cells with a side on the edge of the shape: where a door in the outer wall can be.
BoxtypeA rectangle, in cells.
buildMazefunctionMake the maze a recipe names.
buildMixedfunctionBuild the maze and locked-arrow layers of one native mixed recipe.
canLayStonefunctionWhether a stone may be laid on a cell now, and if not, why not.
carveMazefunctionThe open neighbours of every cell, for a perfect maze of the grid made by this algorithm from this stream.
CellGraphtypeWhat a generator reads of a grid: how many cells there are and which are beside which.
cellsAlongfunctionThe cells a pointer enters moving from one shown point to the next: the straight path between them cut into steps of a third of a cell and each step carried back into the maze.
centreCellfunctionThe cell whose middle is nearest the middle of the shape.
circleGridfunctionA circle maze: rings rings round a middle cell, cells running round each ring and out between the rings.
clearArrowsfunctionTake every arrow off by tapping only free ones, the way a test or a demo plays.
clearStonesfunctionEvery stone taken up, in one step Undo can put back.
COVER_FROMconstantWhere cover begins to rise and how far it rises: (mean - COVER_FROM) / COVER_SPAN.
COVER_SPANconstantThe native coverage span used by the geometry-aware score.
COVERAGE_FLOORconstantWhat the score is multiplied by at no cover at all.
coverageOffunctionHow much of a map an answer covers.
decodeRunfunctionThe game a run text says, for maze under rules, or null when it is not a run of that maze: a step into a wall or back onto the line, a stone on a cell the line is on, on the start or the goal, on no cell at all or twice, or any stones when rules is null.
DIFFICULTY_CEILINGSconstantThe count at which a term reaches its full weight, on its log scale.
DIFFICULTY_WEIGHTSconstantWhat each term is weighed by in the score; they add to 1.
difficultyOffunctionHow hard a maze is, from 0 to 100, and what that is made of.
difficultyOfGraphfunctionThe same for any maze, flat or over a solid, given how it lies in space (MazeGeometry).
DoortypeA door in the outer wall: the cell it is beside, and which of that cell's sides.
dragMazefunctionThe finger moved into a cell.
easyFloorAtfunctionWhat the easy third asks for beyond the least, rising through it so that it climbs: at place place (from 1) of a size, a maze has at least this many traps, forks and wasted cells, and from the end of the easy third the least.
EFFORT_LEASTconstantThe easiest effort a level is given a rating for, and the hardest: 1 and 100 are these.
EFFORT_MOSTconstantThe upper native effort bound used when converting effort to a rating.
encodeRunfunctionA run kept as one short text: the line as its steps (lineToSteps), and, if any stones are down, a ~ and their cells in base 36 joined by dots, such as 0231~1a.2f.
GridtypeThe native flat cell graph with geometry, neighbour sides, bounds and point-to-cell lookup.
gridOffunctionA grid by name.
hasStonefunctionWhether a cell has a stone on it.
headOffunctionThe end of the line, or null while there is none.
heldByLocksfunctionWhether an arrow cannot be cleared before the unlock whatever the player taps: with every free arrow taken off, one after another, it is still on the board.
hexGridfunctionColumns by rows of hexagons, pointy side up, every odd row shifted half a cell right.
hintArrowfunctionThe arrow to tap next: one that is free now and keeps the most arrows waiting behind it, so it also frees the most others.
hintMazefunctionWhere to look next: how many cells of the line to draw back (the part that has strayed from the way to what is still needed), and the next stretch of the right way from there, up to ahead cells, not counting the one the line is on.
isFreefunctionWhether an arrow can be tapped now and slide off: it is on the board, not locked, and nothing is in front of it.
isPerfectfunctionWhether the passages are a spanning tree of the grid: every cell reached, and exactly one way to each.
isTooEasyfunctionWhether a maze is too easy to be a level: it falls short of any of MEIKYUU_LEAST, or, with a place in the easy third of a size, of easyFloorAt(place).
layoutCellsfunctionHow many cells laying out a recipe's grid takes, counted before anything is built: the grid's own cells for squares, hexagons, triangles and circles, and the whole raster for a shape cut out of one (a cut-out shape keeps fewer, but is built from all of them).
layStonefunctionThe game with a stone laid on the cell; the same game when it may not be (canLayStone).
liftMazefunctionThe finger lifted.
lineToStepsfunctionA line, cell by cell from the start, as its steps.
LinkstypeEach cell's open neighbours.
makeArrowsfunctionThe arrows of a recipe, in the order they were added: the last one added is free from the start.
MasktypeTHE OUTLINES cut out of a square raster: a function from a point of the square (both numbers from -1 to 1, y down) to whether that point is inside the shape.
maskOffunctionThe outline a raster shape is cut with.
MazetypeA seeded flat maze with its cell graph, passages, doors, endpoints and optional keys.
MazeCoretypeWhat the game, the stones, the measure and the steps read of a maze: the passages, the two ends, the keys, and how many cells there are and which are beside which.
MazeCoveragetypeHOW MUCH OF THE MAP THE ANSWER COVERS (coverageOf): the second half of a maze's difficulty.
MazeDifficultytypeHOW HARD A MAZE IS TO PLAY, ON ONE SCALE FROM 0 TO 100 (difficultyOf).
MazeGametypeA 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.
MazeGeometrytypeHow a maze lies in space, which is all the measure needs to know of it besides the passages: how far a cell is from the goal (any measure that rises with distance will do, the squared distance is cheapest) and how far the line bends going from one cell through another to a third, in radians from 0 (straight on) to pi (back the way it came).
MazeMeasuretypeHOW HARD A MAZE IS, measured from the maze alone (docs/MAZES.md says why each number is here).
mazeProgressfunctionHow far the line has got, for a progress line: cells drawn, keys, and whether it is solved.
MazeRecipetypeEverything that makes a maze.
measureArrowsfunctionMeasure the arrow count, cells, dependency rounds and native clearing effort.
measureMazefunctionMeasure a maze.
measureMixedfunctionHow hard it is: the arrows' effort and half the labyrinth's.
MEIKYUU_ALGORITHMSconstantTHE SEVEN WAYS TO MAKE A PERFECT MAZE, each over any grid: a perfect maze is a spanning tree of the cells, so there is exactly one way between any two of them.
MEIKYUU_EASY_PLACESconstantHow far up a size the easy third reaches: its first 86 places.
MEIKYUU_LEASTconstantThe least a maze must have to be a level at all, wherever it is in a list (isTooEasy): the straight guess draws at least four cells it did not need, is wrong at two forks or more, and the way has three places to choose, three wrong branches and four dead ends.
MEIKYUU_MODESconstantA MAZE: a grid, the passages carved through it (always a spanning tree, so exactly one way between any two cells), and how it is played.
MEIKYUU_MOST_ARROW_CELLSconstantThe most cells an arrow board may have: a little over twice the biggest level's (1,849).
MEIKYUU_MOST_CELLSconstantThe most cells a recipe may lay out: a little over twice what the biggest level does (19,321, a heart, leaf, star or moon cut from a raster 139 across).
MEIKYUU_MOST_KEYSconstantThe most keys a recipe may ask for: twice the most any level uses (five).
MEIKYUU_ORIENTATIONSconstantWHICH WAY UP A MAZE IS LOOKED AT.
MEIKYUU_SHAPESconstantEvery shape a maze can be made on.
MEIKYUU_STONE_REACH_MOSTconstantThe farthest a stone may be from the line: two cells.
MeikyuuAlgorithmtypeOne of the seven native maze-carving algorithms.
MeikyuuModetypeThe enter/leave, goal, centre-out or key-collecting native maze mode.
MeikyuuOrientationtypeThe native portrait, landscape or automatic board orientation.
MeikyuuShapetypeA supported flat grid geometry or cut-out mask.
MixedBoardtypeA native mixed recipe with its flat maze and arrow layers.
MixedGametypeThe current native maze and arrow states of one mixed puzzle.
MixedRecipetypeTHE MIXED PUZZLE: an arrow board with some arrows locked, and a labyrinth beside it with an unlock button hidden deep inside.
mixedRecipeCodefunctionEncode a native mixed maze/arrow recipe as reproducible text.
mixedSolvedfunctionWhether the puzzle is won: every arrow cleared.
newArrowGamefunctionCreate the native arrow state with all arrows present and a starting heart count.
newMazeGamefunctionA game of the maze, with nothing drawn, and, if given, the rules of its stones (stones.ts).
newMixedGamefunctionCreate the native game states for both layers of a mixed board.
parseArrowRecipefunctionA recipe's arrow board from its code, or null when it is not one, or names a board bigger than MEIKYUU_MOST_ARROW_CELLS.
parseMixedRecipefunctionRead native mixed-recipe text, or null for a malformed maze/arrow recipe.
parseRecipefunctionA recipe from its code, or null when it is not one, or names a maze bigger than MEIKYUU_MOST_CELLS or more keys than MEIKYUU_MOST_KEYS.
passageCountfunctionHow many passages the maze has: one fewer than its cells, if it is perfect.
peelRoundsfunctionThe order the arrows come off in if every free one is taken each round, as rounds: the length of this is how many times the board has to be looked at again.
pickfunctionOne of the items, chosen from the stream.
playSolutionfunctionDraw the maze's whole solution through the game, a cell at a time, as a finger would: the way a test or a demo plays.
PointtypeA point, [x, y], in cells.
pressMazefunctionA finger down on a cell: it begins a stroke if the cell is the start, the line's end, or on the line.
RandomtypeA number in [0, 1), like Math.random, from a stream a seed fixes.
ratingOffunctionAn effort as a rating from 1 to 100, on a scale where doubling the effort adds the same each time.
rayOffunctionThe cells in front of an arrow's head, out to the edge of the board, nearest first.
recipeCodefunctionA recipe as one short word, such as square:12x9:wilson:to-goal:48213 or heart:25:prim:keys-3:7, and the other way (parseRecipe).
resolveTurnfunctionThe turn an orientation means for a maze, given the room when it is auto.
restartArrowsfunctionRestore every native arrow and the original hearts, clearing mistakes and removals.
restartMazefunctionEverything off the maze again.
ringCountsfunctionHow many cells each ring of a circle maze holds: one in the middle, six round it, and a ring doubles its cells when its cells would otherwise be wider than tall.
seededRandomfunctionA stream of numbers in [0, 1) fixed by a seed.
shuffledfunctionA copy of the list in a random order (Fisher–Yates); the list given is left alone.
SidetypeOne side of a cell: the cell across it (-1 for the edge of the shape) and the wall it is drawn with.
SOLID_ZONES_TOPconstantHow much of a solid's zones even a whole tour touches.
solutionOffunctionThe one way from the start to the goal, cell by cell, both ends included.
squareGridfunctionColumns by rows of square cells.
stepsToLinefunctionThe cells steps walk from the maze's start, or null if any step goes where a line cannot: into a wall, off the maze, or back onto the line.
stoneLimitForfunctionHow many stones a maze of cells cells gets by default: three, and one more for every hundred cells across (so four for a small maze, nine for a huge one, thirteen for a colossal one).
StoneOptiontypeWhat the stones option of mountMeikyuu takes: true for the defaults, or any of the rules (limit: null for no limit).
StoneRulestypeSTONES: a marble laid on a cell of the maze that the line may not enter.
stoneRulesOffunctionThe rules an option means for a maze of cells cells, or null when the option is no stones.
stonesLeftfunctionHow many stones can still be laid: null for no limit, and nought for a game with none.
StoneVerdicttypeWhy a stone cannot be laid on a cell, or ok.
takeStonefunctionThe game with the stone on the cell taken up (and given back); the same game when there is none.
TALL_RATIOconstantThe ratio of a tall container, width over height: two to three.
TALL_SHAPESconstantThe shapes that are made tall.
TALL_WIDTHSconstantHow many cells across each size of the tall levels is.
tallDimensionsfunctionThe columns and rows of a maze of shape for the size width (a square maze of that size is width by one and a half times that): as near 2:3 as its cells allow, and with about as many cells as that square maze has (width times one and a half width), so that the sizes are as big to draw whatever the shape is.
tapArrowfunctionAttempt to remove a native arrow and return the new game and removed/blocked/locked/ignored result.
tapMazefunctionA tap on a cell: the line runs along the passage toward it as far as the next place it could have gone another way, or to the cell itself if that comes first.
toDisplayfunctionA logical point as it is shown.
toggleStonefunctionA tap on a cell: a stone there is taken up, and otherwise one is laid.
toLogicalfunctionA point of the picture as the maze has it: the inverse of toDisplay.
triangleGridfunctionRows of triangles, each pointing up or down in turn, w to a row; a cell is up when its column and row make an even number.
Turntype0 for a maze shown as it was made, 1 for a quarter turn counter-clockwise.
turnedBoxfunctionThe rectangle a logical rectangle takes when shown.
turnForfunctionWhether to turn a maze box (as made) for an orientation.
turnTransformfunctionThe SVG transform that shows a logical drawing turned, or none.
undoArrowfunctionPut the last arrow taken back, and give back no heart.
undoMazefunctionPut the whole line back as it was before the last stroke.
unlockArrowsfunctionLet the locked arrows be tapped.
unturnedBoxfunctionThe logical rectangle a shown rectangle covers: the inverse of turnedBox.
VERSIONconstantThe package's version.
walkfunctionHow far every cell is from from along the passages, and the cell before it on the way: -1 where unreachable.
WalltypeThe line a wall is drawn along, from a to b.
withArrowsfunctionThe arrows changed.
withMazefunctionThe labyrinth changed: when its button is reached, every locked arrow is unlocked.
withStoneRulesfunctionThe same game under other rules (the limit or the reach changed, or stones turned on or off): the stones down stay down, and none is ever taken off by a lower limit, only no more laid.
ZONE_REALconstantA zone with less than this share of an average zone's cells is not a zone (a cross's corners, a ring's hole).
ZONE_VISITconstantThe cells of the answer a zone must hold to be visited.
zonesAcrossfunctionHow many zones along each axis a map of cells is cut into: a flat map by 2, 3 or 4, a solid by 2 or 3.

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