本文へ移動

Jirai地雷

シード付きの地雷の盤を作り、見える数字からヒントを証明し、四角・四近傍・六角・端がつながる盤で遊べます。

「地雷」は、地面に埋められた爆弾のことです。 名前について(英語)

目次

リファレンス

規則・生成・推論

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

最小化と gzip 圧縮をしたサイズは 7.8 kB(読み込むものをすべて含み、esbuild で計測)

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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

エクスポート

名前種類概要
activeCell関数Row-major addresses stay stable; omitted cells have no clue and no neighbours.
activeCells関数Returns all active cells in stable row-major order.
Board型A dealt board including its answer; keep it off public clients.
Constraint型An exact count over unknown cells, with the clues that supplied it.
dailySeed関数UTC by definition, so two people sharing a daily seed get the same board.
decodeOrthogonalGame関数Restores only version 2 orthogonal progress records.
deduce関数What the clues prove, without reading the answer or trusting a player's flags.
Deduction型Certain safe cells and mines proved from visible clues.
DEFAULT_SETTINGS定数Default easy game, with a verified no-guess board and clear opening.
encodeOrthogonalGame関数Encodes an orthogonal game with an explicit variant marker and version 2.
ENUMERATION_CELLS定数Largest frontier enumerated for exact deductions.
ENUMERATION_NODES定数Maximum partial assignments checked in one exact deduction search.
Game型Rules data includes the answer; never send it to a competitive client.
gameFromProgress関数A saved game is rebuilt under the rules.
gameProgress関数Keep settings and moves, never an unchecked answer array.
GENERATION_ATTEMPTS定数Default number of random layouts tried before a no-guess deal falls back to repairing the closest one.
GenerationErrorクラスA bounded generator must say it failed, never quietly return a guessing board.
GenerationOptions型Work limits for seeded board generation and its no-guess check.
Grid型Neighbour topology used to count the clues around each cell.
GRID_SPECS定数Neighbour offsets and edge behaviour for each topology.
GRIDS定数Names for the supported square, four-neighbour, hex, and wrap grids.
hintFor関数Keep discovering certain mines until there is a safe cell or nothing more is proved.
HUGE_SIZES定数The huge fields: four times the area of a 16×16 (the medium level), 1,024 to 1,152 squares, for a long solve.
hugeSettings関数The 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.
HugeSize型The outline of a huge field: one of HUGE_SIZES' width and height.
isSolvable関数Verify a board from one opening, using only clues that have been uncovered.
Language型Supported interface copy locales.
Level型A difficulty level: easy, medium, hard or extra-hard.
LEVEL_ALIASES定数The 0.1 and 0.2 names for the first three levels.
LEVEL_SIZES定数Size and mine count of each level on a rectangular board.
LevelAlias型The 0.1 and 0.2 names for easy, medium and hard, still accepted wherever a level is.
levelNamed関数The level a name means, or null.
LEVELS定数The four difficulty levels, easiest first.
levelSettings関数The size and mine count of a level.
LevelSize型Board size and mine count a level asks for.
makeBoard関数Deal after the first reveal.
makeOrthogonalBoard関数Deals a board whose clues count only up, down, left and right.
Mark型Player-facing state of one cell; the answer is never a mark.
MARKS定数Names for the cell mark cycle.
Material型Board colours for drawing and mounted play.
MAX_CELLS定数Largest total cell count accepted by settings validation.
MAX_SIDE定数Largest width or height accepted by settings validation.
Measure型How demanding a dealt board is to solve by deduction, measured by solving it.
measureBoard関数Solve a dealt board from its opening and report what it took.
Move型A reveal, mark-cycle, or numbered-cell chord applied to a game.
MOVES定数Names for the moves accepted by the engine.
neighbours関数Every neighbour once.
neighboursOf関数Precomputes the neighbour list for each row-major cell.
newGame関数Creates an unstarted game with covered cells and no dealt answer.
newOrthogonalGame関数Starts a game under four-neighbour rules.
ORTHOGONAL_VARIANT定数Identifies the four-neighbour rules and progress-code format.
orthogonalHint関数Gives a clue-only deduction; flags remain notes and cannot influence the result.
orthogonalNeighbours関数Returns the adjacent cells under the orthogonal rules.
OrthogonalSettings型Settings accepted by the four-neighbour-specific helpers.
Pieces型Symbols used to mark mines.
play関数A legal move returns a new game; an unavailable move returns the same one.
PRESETS定数Common minefield dimensions and mine counts.
ProofKind型Why a cell was proved: one clue, two overlapping clues, the mine counter, or every arrangement of a small frontier.
ProofTally型Cells proved by each kind of reasoning.
seededRandom関数Mulberry32, pinned by the replay tests: changing it would change every kept board.
Settings型Board dimensions and rules used to deal and validate a game.
SHAPES定数Board silhouettes supported by settings.
Status型Current game state, including whether a mine has been hit.
STATUSES定数Names for the game lifecycle states.
validCell関数Reports whether a row-major cell is inside the board's active shape.
validSettings関数Reject a setting before it reaches a board allocation or a shuffle.
VERSION定数Package version, kept in step with the release metadata.
visibleGame関数The clue-only view used by the solver.
VisibleGame型Answer-free state suitable for deductions, hints, and public display.
withBoard関数Attaches a worker-dealt board that matches the game's settings, preserving existing moves.

ソースを見るGitHub で編集@johnmorrisdotca/jirai 0.5.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。