Skip to the content

Jirai地雷

Deal seeded minefields, prove hints from visible clues and mount square, orthogonal, hexagonal or wraparound boards.

Jirai is the Japanese word 地雷 for a land mine. About the name

Contents

Reference

Rules, generation and deductions

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

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

Jirai 地雷: the rules and deductions, plain functions over plain data. No DOM and no dependencies.

Exports

NameKindWhat it is
activeCellfunctionRow-major addresses stay stable; omitted cells have no clue and no neighbours.
activeCellsfunctionReturns all active cells in stable row-major order.
BoardtypeA dealt board including its answer; keep it off public clients.
ConstrainttypeAn exact count over unknown cells, with the clues that supplied it.
dailySeedfunctionUTC by definition, so two people sharing a daily seed get the same board.
decodeOrthogonalGamefunctionRestores only version 2 orthogonal progress records.
deducefunctionWhat the clues prove, without reading the answer or trusting a player's flags.
DeductiontypeCertain safe cells and mines proved from visible clues.
DEFAULT_SETTINGSconstantDefault easy game, with a verified no-guess board and clear opening.
encodeOrthogonalGamefunctionEncodes an orthogonal game with an explicit variant marker and version 2.
ENUMERATION_CELLSconstantLargest frontier enumerated for exact deductions.
ENUMERATION_NODESconstantMaximum partial assignments checked in one exact deduction search.
GametypeRules data includes the answer; never send it to a competitive client.
gameFromProgressfunctionA saved game is rebuilt under the rules.
gameProgressfunctionKeep settings and moves, never an unchecked answer array.
GENERATION_ATTEMPTSconstantDefault number of random layouts tried before a no-guess deal falls back to repairing the closest one.
GenerationErrorclassA bounded generator must say it failed, never quietly return a guessing board.
GenerationOptionstypeWork limits for seeded board generation and its no-guess check.
GridtypeNeighbour topology used to count the clues around each cell.
GRID_SPECSconstantNeighbour offsets and edge behaviour for each topology.
GRIDSconstantNames for the supported square, four-neighbour, hex, and wrap grids.
hintForfunctionKeep discovering certain mines until there is a safe cell or nothing more is proved.
HUGE_SIZESconstantThe huge fields: four times the area of a 16×16 (the medium level), 1,024 to 1,152 squares, for a long solve.
hugeSettingsfunctionThe size and mine count of a level on a huge field: a field of HUGE_SIZES (32 × 32 unless size says another of them), with the level's own share of mines over its squares.
HugeSizetypeThe outline of a huge field: one of HUGE_SIZES' width and height.
isSolvablefunctionVerify a board from one opening, using only clues that have been uncovered.
LanguagetypeSupported interface copy locales.
LeveltypeA difficulty level: easy, medium, hard or extra-hard.
LEVEL_ALIASESconstantThe 0.1 and 0.2 names for the first three levels.
LEVEL_SIZESconstantSize and mine count of each level on a rectangular board.
LevelAliastypeThe 0.1 and 0.2 names for easy, medium and hard, still accepted wherever a level is.
levelNamedfunctionThe level a name means, or null.
LEVELSconstantThe four difficulty levels, easiest first.
levelSettingsfunctionThe size and mine count of a level.
LevelSizetypeBoard size and mine count a level asks for.
makeBoardfunctionDeal after the first reveal.
makeOrthogonalBoardfunctionDeals a board whose clues count only up, down, left and right.
MarktypePlayer-facing state of one cell; the answer is never a mark.
MARKSconstantNames for the cell mark cycle.
MaterialtypeBoard colours for drawing and mounted play.
MAX_CELLSconstantLargest total cell count accepted by settings validation.
MAX_SIDEconstantLargest width or height accepted by settings validation.
MeasuretypeHow demanding a dealt board is to solve by deduction, measured by solving it.
measureBoardfunctionSolve a dealt board from its opening and report what it took.
MovetypeA reveal, mark-cycle, or numbered-cell chord applied to a game.
MOVESconstantNames for the moves accepted by the engine.
neighboursfunctionEvery neighbour once.
neighboursOffunctionPrecomputes the neighbour list for each row-major cell.
newGamefunctionCreates an unstarted game with covered cells and no dealt answer.
newOrthogonalGamefunctionStarts a game under four-neighbour rules.
ORTHOGONAL_VARIANTconstantIdentifies the four-neighbour rules and progress-code format.
orthogonalHintfunctionGives a clue-only deduction; flags remain notes and cannot influence the result.
orthogonalNeighboursfunctionReturns the adjacent cells under the orthogonal rules.
OrthogonalSettingstypeSettings accepted by the four-neighbour-specific helpers.
PiecestypeSymbols used to mark mines.
playfunctionA legal move returns a new game; an unavailable move returns the same one.
PRESETSconstantCommon minefield dimensions and mine counts.
ProofKindtypeWhy a cell was proved: one clue, two overlapping clues, the mine counter, or every arrangement of a small frontier.
ProofTallytypeCells proved by each kind of reasoning.
seededRandomfunctionMulberry32, pinned by the replay tests: changing it would change every kept board.
SettingstypeBoard dimensions and rules used to deal and validate a game.
SHAPESconstantBoard silhouettes supported by settings.
StatustypeCurrent game state, including whether a mine has been hit.
STATUSESconstantNames for the game lifecycle states.
validCellfunctionReports whether a row-major cell is inside the board's active shape.
validSettingsfunctionReject a setting before it reaches a board allocation or a shuffle.
VERSIONconstantPackage version, kept in step with the release metadata.
visibleGamefunctionThe clue-only view used by the solver.
VisibleGametypeAnswer-free state suitable for deductions, hints, and public display.
withBoardfunctionAttaches a worker-dealt board that matches the game's settings, preserving existing moves.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/jirai 0.5.0.