本文へ移動

Narabe並べ

48種類の盤上ゲームを、新しい局面を返す手の操作、合法手の一覧、再生できる棋譜で扱えます。

「並べ」は五目並べの「並べ」。石を並べることを表す言葉です。 名前について(英語)

目次

リファレンス

ルールと棋譜

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

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

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

Narabe 並べ: one rules engine for forty-eight abstract board games.

Every game is a row of data (VARIANT_SPECS), and every function takes a GameState and returns a new one. Start with createGame, play with playMove, movePiece, placePiece, twistBoard or passTurn, and ask turnChoices what the player to move may do. Records are plain move lists: replayMoves and replayGame read them back, undoMove steps one back.

Deeper pieces (each rule module on its own) are reachable by path as well, for example @johnmorrisdotca/narabe/rules/go.

エクスポート

名前種類概要
ALL_BOARD_SIZES定数Every size any game here is played on, for the schemas at the API edge.
availableOpenings関数The openings these settings may use: what the variant offers, less the colour-swapping ones when a handicap is bound to a colour — and only the free opening under a head start.
Blocked型An intersection the rules have taken out of play.
BLOCKED定数The unavailable-cell marker.
BOARD_GRIDS定数Where a game's stones sit when it is drawn its own way: on the crossings, or in the squares.
BOARD_SIZES定数Board is size × size.
BoardGrid型Where a game's stones sit when it is drawn the way it is traditionally played: on the crossings of the lines, as in go and gomoku, or inside the squares, as in tic-tac-toe, Othello and checkers.
boardSizesFor関数The board sizes a variant plays on, smallest first — the order they are drawn in.
BRAZILIAN_DRAUGHTS_RULES定数Brazilian draughts: the international rules of capture and crowning on 8×8, with twelve men, and the draws of the Brazilian confederation's own rules (CBJD, Regras Oficiais) rather than the FMJD's 8×8 set, which differs.
campOf関数Whose home camp point lies in, or null for the open board.
campSize関数Pieces a side has on size: the squares of its camp.
campSquares関数The squares of a colour's home camp.
CANADIAN_CHECKERS_RULES定数Canadian checkers: the international rules on 12×12, thirty men a side in five rows.
canBeDrawn関数Whether this game can be drawn at all.
canChooseColour関数Whether the game is waiting on a seat to pick a colour.
canExtendOpening関数Swap2 only: the first chooser may add two stones and pass the choice back.
canForfeit関数Whether a recorded forfeit could have been written here: only where the clock had no pass to write instead.
canGrowBoard関数Whether resizing is enabled and a larger native board is available.
canPass関数Whether passing is on offer: forced in a piece game with nothing to lay, free at any point in Go.
canShrinkBoard関数Whether resizing is enabled and a smaller native board is available.
canSkip関数Whether skipping is enabled and a legal corner stone can burn the turn.
canSwapSeats関数Whether the seat to play may trade seats right now.
canTwist関数Whether the colour to move owes a quarter turn before the move is complete.
canUndo関数Whether undo is enabled and a recorded move can be removed.
CAPTURE_CHOICES定数The free-choice and maximum-capture draughts modes.
CaptureChoice型Which capture a checkers-family player may choose, when more than one is on offer.
capturePaths関数The squares each capture has passed through so far, move by move, or null for a move that took nothing.
Cell型One intersection of the board: a stone, an obstacle, a hotspot, a wormhole, or nothing.
cellAt関数Read a cell from a valid zero-based board point; null means empty.
centreSquares関数The four centre squares, top-left first.
checkersHasCapture関数Whether any of stone's pieces on the board has a capture available right now.
CheckersRules型How one game of the checkers family is played, as data: the rows of men each side sets out, which way a man may take, how far a king may travel, which capture must be chosen, and what crowning does to a capture under way.
chooseColour関数The deciding seat takes stone.
ColourRules型The rules one colour actually plays under: the variant's spec for that colour with the handicap laid over it.
COLUMN_LETTERS定数Column letters used in coordinate labels, left to right.
columnLetter関数Column letter, left to right: A, B, C ...
createGame関数Create an initial immutable position from native settings and an opening roll.
CROWN_MID_CAPTURE定数The supported promotion behavior during a capture chain.
CrownMidCapture型What becomes of a man that reaches the far row in the middle of a capture.
DEFAULT_BOARD_SIZE定数The default side length for an unconstrained board.
DEFAULT_CAPTURES_TO_WIN定数Enemy stones to capture for a win in the capture game: five pairs.
DEFAULT_SETTINGS定数The defaults used when creating a game without overrides.
DEFAULT_SWAPS_PER_SEAT定数The default seat-swap allowance for each player.
defaultBoardFor関数The board a game OPENS on, where nothing else has said: its own defaultBoard if it has one, else the first of its boards.
DIRECTIONS定数The four line orientations through a point.
discCount関数Count black and white discs currently on a board.
DRAW_LIMIT_LIST定数The selectable configured game-length limits.
DRAW_LIMIT_MIN_POINTS定数The smallest board a length means anything on, in points.
DRAW_LIMIT_SHARE定数The board fractions used by configured draw limits.
DRAW_LIMITS定数The shares of the board a game may be called a draw at.
DrawLimit型When a game nobody has won is called a draw.
drawnByLength関数Whether a finished game was drawn because it ran to its length, rather than because the board filled or both sides made a line at once.
dropTarget関数Where a stone dropped into col lands, or null when the column is full.
emptyPoints関数Every intersection still open: no stone, no obstacle.
endedWithNoMoves関数Whether the game ended because neither side had a move: two forced passes, the last two moves on the record.
ENDGAME_COUNT_KINDS定数The specific-ending and material-balance draw count modes.
EndgameCount型An ending that must be won within so many moves or it is a draw, once each player has made movesEach more moves inside it.
EndgameCountKind型The two shapes an endgame count is written in — see EndgameCount.
endsOnItsOwn関数Whether the rules alone guarantee this game ends.
ENGLISH_CHECKERS_RULES定数English draughts, American checkers: three rows of men, a man takes forward only, a king moves one square, any capture may be chosen, and a man crowned by a capture ends the move there.
extendOpening関数The chooser declines to choose and lays two more stones instead.
findWinningLine関数The winning line through point, if the stone there completes one under the rule that applies to its colour.
FIRST_PLAYERS定数The supported opening colours and random opener choice.
FIRST_STONE定数Black opens unless the settings say otherwise.
FirstPlayer型Who opens.
flipsAt関数The discs a stone of stone at point would turn.
footprintAt関数The absolute cells of an orientation anchored with its origin at anchor.
footprintFits関数Whether every cell of a footprint is on the board and empty.
FORBIDDEN_PATTERNS定数The named forbidden shapes checked by line games.
forbiddenAt関数Why stone may not play point, or null when it may.
ForbiddenPattern型Shapes a colour may be forbidden from making.
forbiddenPoints関数Every empty point the colour to move is forbidden from playing right now.
forbiddenReason関数Why the colour to move may not play point, when a forbidden shape is why.
forfeitOnRecord関数A missed turn, as the position the record will replay it to.
forfeitTurn関数Takes the turn away from the colour to move without a stone: the graceful penalty for a missed deadline.
GAME_STATUS定数The playing, won and drawn outcome labels.
GameSettings型Native rule, layout, opening, handicap and optional action settings.
GameState型The complete immutable position and its move history, seats and outcome.
GameStatus型Whether the game is playing, won or drawn.
groupAt関数The connected group of stones sharing the colour at from, and the empty points touching any of them — its liberties.
growBoard関数Returns the game on a larger board, or the state unchanged when it cannot grow.
Handicap型Extra restrictions one colour plays under, so a stronger player can give a weaker one a fair game.
HANDICAP_RULES定数The handicap toggles, in the order the settings list them.
HandicapRule型The toggles of a handicap, without the colour that carries them.
HandicapTerms型EVERYTHING THAT MAKES A GAME UNEVEN ON PURPOSE, as hasHandicap reads it: the per-colour handicap and the head start.
hasFlipMove関数Whether the colour has a legal disc-flipping move.
hasHandicap関数Whether any handicap is in force for anyone: harder rules for one colour, or a head start for one.
HEAD_START_FREE_TURNS定数The free turns a head start may give, none included.
HeadStart型A start given to one colour — the weaker player's — before the game is even.
HeadStartTurns型The most free turns a game offers as a head start: 0 where it offers none.
HEX_LINE_DIRECTIONS定数The three line orientations on the hexagon lattice — see rules/hexagon.ts for the embedding.
Hot型A hotspot: an intersection that counts as either colour's stone in a line.
HOT定数The cell marker that counts as either colour in a line.
indexOf関数Convert a board point into its row-major array index.
inLayingPhase関数Classic reversi: the first four discs are laid by the players, in the centre, with no flipping.
inMovePhase関数Whether the colour to move has all its pieces down and must now slide one.
INTERNATIONAL_DRAUGHTS_RULES定数International draughts, from the FMJD's official rules (Annex 1, 2018, and the 2024 Annexes).
isDarkSquare関数Checkers is played on one colour of square only: the board's own dark squares.
isKingAt関数Whether the piece at at, if any, is a king.
isLegalMove関数Whether the colour to move may play point: on the board, empty, allowed by the opening, not a shape the variant forbids that colour, the landing cell of its column in a drop game, and not while a twist or a slide is owed.
isOnBoard関数Whether both coordinates are within the square board.
isStone関数Narrows a cell to a played stone, excluding empties and obstacles.
KOMI定数Go: stones never move once played, and nothing about a line ever decides anything.
landingPoints関数The one landing cell per column with room: the only cells a drop can fill.
lastMove関数The point of the latest stone or piece move; null when no point was played.
leavesNoStone関数Whether a recorded move put nothing on the board: a pass, or a turn the clock took away.
legalPoints関数Every intersection the colour to move may play right now.
LINE_RULES定数The at-least, exact and open-exact winning line modes.
lineDirectionsFor関数The directions a winning line may run: the hexagon's three axes on a hexagon board, the square's four otherwise.
LineRule型What a completed line has to look like to win.
longestPossibleGame関数The most moves a game of these settings can contain, or null when nothing in the rules bounds it.
Move型A move rebuilt by the engine, including captures and other replay effects.
MOVE_KINDS定数The stable labels used in move records.
MOVE_NARROWINGS定数The reasons a move list is restricted to captures.
MoveInput型The shape of a move as a record or a request carries it, without the colour.
MoveKind型place: an ordinary stone.
MoveNarrowing型A rule that has narrowed the moves on offer below what the pieces could make: a capture that must be made, or carried on, instead of a step; or — where the game takes the most — the capture taking the most pieces, over shorter ones the pieces also have.
movePiece関数Slides a piece one step, or in checkers a step or a capture.
movesBeforeDraw関数How many moves may be played before a game nobody has won is a draw, or null when it is to be played out.
mustPass関数Whether the colour to move has nothing it may play.
nextBoardSize関数The next size up, or null when the board is already the largest.
NO_HANDICAP定数The default terms with no colour-bound rule restrictions.
NO_HEAD_START定数Nobody given a start: the even game, which is most games.
NO_POINT定数A pass has no point on the board.
noBoundReason関数What stops this game being bounded by its board, or null when nothing does.
NoBoundReason型Why a game has no bound, or null when the board is its bound.
normaliseSettings関数Settings that agree with their variant: a pinned line length wins over the player's choice, an opening the variant does not offer falls back to free, and a handicap rules out the openings that swap colours.
OBSTACLE_LAYOUTS定数The native empty and star-point obstacle layouts.
ObstacleLayout型none: every intersection is playable.
OPENING_CHOICE_EXTEND定数The one opening choice that is not a colour.
OPENING_RULE_LIST定数All supported opening identifiers in display order.
OPENING_RULES定数The stable identifiers for supported opening protocols.
OPENING_STAGES定数The stages of the opening protocol.
OpeningChoice型A decision taken during the opening: a colour, or two more stones.
OpeningRule型How the first stones go down.
OpeningStage型Where a swap-style opening stands.
OpeningState型The opening protocol stage, acting seat and recorded colour choices.
orientations関数Every distinct way the piece can lie: four rotations, each also mirrored.
orientCells関数The piece turned turns quarter turns and, if asked, mirrored — the shape a player has in hand.
otherStone関数The other stone colour.
passesOwed関数The position after every pass the rules force: none when the colour to move has something to play, one when only it is stuck, and two — ending the game — when neither side can move.
passTurn関数Takes a turn without a stone.
Piece型A piece from the queue: its cells relative to the top-left of its bounding box.
PIECE_PREVIEW定数How many queued pieces a player is shown ahead of the one in hand.
PIECE_QUEUES定数The domino and tetromino queue identifiers.
PieceCell型One cell of a multi-cell piece, with the colour it carries.
pieceMoves関数Where a piece of the colour to move may step from from; empty if it may not move.
piecePlacements関数Every legal footprint of the piece in hand.
PieceQueue型Which queue of pieces a game draws from.
piecesHome関数How many of stone's pieces stand in the far camp.
PieceTally型A side's pieces, as an endgame count names them.
Placement型Where a stone goes when played.
PLACEMENTS定数The free, dropped and supported-edge placement modes.
placePiece関数Lays the piece in hand on cells.
playMove関数Plays the stone to move at point.
Point型Zero-based board coordinates.
pointName関数Renju-style name for an intersection, e.g.
pointOf関数Convert a row-major array index into board coordinates.
POOL_CHECKERS_RULES定数Pool checkers, from the American Pool Checker Association's Tournament Rules of Play (2016): men take both ways (rule 14), kings fly (15, 18), any capture may be chosen — "not compelled to take the greater or lesser number" (20) — and a capture once begun is completed (21).
previousBoardSize関数The next size down, or null when the board is already the smallest.
quadrantCount関数How many quadrants a board of this size holds.
quadrantOrigin関数The top-left corner of quadrant quadrant.
queuedPiece関数The piece the colour to move must lay next, or null outside the piece games.
ReplayFacts型What a replay needs to know about a record that its moves cannot say.
replayGame関数The position as it stands now.
replayMoves関数Replays a record through the engine: every position it passed through, including the ones a swap-opening decision produced.
replayTimeline関数Rebuilds every position a game passed through by replaying its moves.
resign関数Gives the game up.
resolveOpener関数The colour that opens.
resolvePlacement関数Where a stone played at point actually goes: the same point, or in a drop game the bottom of its column.
rowNumber関数Row number counted from the bottom edge, so the bottom row is 1.
RULE_VARIANT_LIST定数The variants in the order the browser and the filters list them.
RULE_VARIANTS定数The stable identifiers for all forty-eight rule variants.
rulesFor関数The rules a colour plays under: the variant's spec for that colour, with the handicap laid over it when the handicap belongs to that colour.
RuleVariant型The named rule sets.
RUSSIAN_DRAUGHTS_RULES定数Russian draughts (shashki), from the Russian Draughts Federation's rules (ФШР, shashki.ru) and the FMJD/IDF rules for 8×8 draughts: men take both ways, kings fly, any capture may be chosen whatever it takes (FMJD-64 4.13), and a man that reaches the far row in the middle of a capture is crowned there and carries on capturing as a king (4.14).
scoreArea関数The area score: every stone on the board, plus every empty region whose only neighbours are one colour.
Seat型The two people at the board.
seatOf関数The seat holding stone right now.
SEATS定数The first and second player seat labels.
seatToPlay関数The seat whose turn it is.
SECOND_STONE_EXCLUSIONS定数Half-widths of the central square a handicapped second stone must leave.
SEED_RANGE定数Seeds are 31-bit integers, small enough for every store and reproducible everywhere.
seededRandom関数A small seeded random number generator, so anything a game decides by chance — where the dead squares fall, which pieces come next — is fixed by the seed stored with the game and comes out the same on every replay.
shrinkBoard関数Returns the game on a smaller board, or the state unchanged when the ring that would be removed is in use.
singlesLeft関数Single stones the colour to move may still lay instead of a piece.
sizeForVariant関数The board this variant will actually be played on, given a size somebody asked for.
skipMove関数Burns the turn on a corner stone.
skipTarget関数Where a skipped turn puts its stone: the open intersection furthest from the action, picked from the corner chosen by roll.
SlideMove型What a record needs of a move to say whether it slid, jumped, or went on jumping.
slideWord関数A slide as the draughts records write it: square to square with an arrow, a capture with a colon (g5:e3), and a multi-jump as every square it landed on (g5:e3:c1).
STAR_POINTS定数Hoshi (star point) positions drawn on the board, by board size: the four corner points, plus tengen at the centre, and for 19×19 the side points too.
STAR_RADIUS定数How many rows deep each of the star's six points is.
starCampOf関数Whose home point point lies in, or null outside both.
starCampSize関数Pieces a side has: the cells of one point, ten on the standard board.
starPiecesHome関数How many of stone's pieces stand in the far point.
starSize関数The side of the square array a star of this radius is embedded in.
STARTING_DISCS定数The fixed, laid or absent starting-disc layouts.
StartingDiscs型How a flipping game begins: nothing, the fixed four, or four the players lay themselves.
Stone型One of the two stone colours.
STONELESS_WORDS定数How a written move list says the two moves that have no point.
stonelessWord関数How a written record says a move with no point, or null for a move that has one.
STONES定数The black and white stone labels.
stonesLeft関数Stones the colour to move still has to place before the turn passes.
StoredGame型The stored shape of a game, as both the API and the pages see it.
swapSeats関数Trades seats: the player to move hands over their colour and takes the opponent's stones instead.
TRADITIONAL_HEAD_STARTS定数The traditional head starts, see TraditionalHeadStart.
TraditionalHeadStart型The head start a game's own tradition gives a weaker player, where it has one: Go's handicap stones on the star points, Othello's corners, and draughts' piece odds, the men taken off the stronger side before the start.
TURN_CHOICE_KINDS定数The piece-moving and stone-placement choice modes.
TurnChoiceKind型Whether a turn moves a piece already on the board, or places on a point.
turnChoices関数What the colour to move may do this turn — every piece that has a move, or every point that may be played — and whether a rule narrowed it.
TurnChoices型What the colour to move may do this turn, as the engine answers it — see turnChoices.
turnPassedBy関数The colour whose turn passed because it had no move, as the latest turn left the board — or null when nobody's did.
Twist型A quarter turn of one quadrant, which ends a move in the twist games.
twistBoard関数Turns one quadrant to finish the move.
undoMove関数Removes the last move, putting back anything it captured, a piece where it came from, and a twisted quadrant the way it was.
upcomingPieces関数The pieces after the one in hand, for the preview.
VARIANT_SPECS定数Every rule set, as data.
VariantSpec型One rule set, as data.
WIN_LENGTH定数Stones in a line needed to win, unless a variant pins it.
WIN_LENGTHS定数Line lengths a player may pick in the variants that leave it open.
WIN_REASONS定数The recorded reasons a game is won.
winOnTime関数Ends the game against a player who has run out of time.
WinReason型How a won game was won.
Worm型A wormhole: a line entering it comes out of its partner and carries on.
WORM定数The linked wormhole-cell marker.
WRAP_MODES定数The supported board edge-wrapping modes.
WrapMode型Which edges of the board join up: a plane, a cylinder, or a torus.

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

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