Skip to the content

Narabe documentation

Narabe API: every export

Every export of every entry point, each with its own page. This page keeps the addresses the old one-page reference had.

@johnmorrisdotca/narabe/react

NarabeGametype

A React game state and its native move, replay and reset actions.

useNarabefunction

One game, kept in React state.

@johnmorrisdotca/narabe/draw

boardSvgfunction

The position as one <svg> element, drawn the way its game is traditionally drawn.

@johnmorrisdotca/narabe/element

defineBoardfunction

Defines the default board or a subclass under a custom tag.

NarabeBoardclass

A board position and keyboard-operable replay of the native game engine.

parseEmbedMovesfunction

Reads a bounded JSON move list for a board embed, or null for malformed input.

@johnmorrisdotca/narabe/element/define

defineBoardfunction

Defines the default board or a subclass under a custom tag.

NarabeBoardclass

A board position and keyboard-operable replay of the native game engine.

parseEmbedMovesfunction

Reads a bounded JSON move list for a board embed, or null for malformed input.

@johnmorrisdotca/narabe/rules/go

applyGoMovefunction

A stone of stone played at point: the board it leaves, and what it captured — or null, meaning the move is suicide and illegal.

areaWinnerfunction

The colour whose area plus komi wins the Go position.

goLegalfunction

Whether stone may play point: on the board, empty, not suicide, and not the one point the simple ko rule forbids retaking this move — exactly the point a single-stone capture just vacated, so the immediate recapture cannot instantly restore the position it broke.

groupAtfunction

The connected group of stones sharing the colour at from, and the empty points touching any of them — its liberties.

KOMIconstant

Go: stones never move once played, and nothing about a line ever decides anything.

playGoMovefunction

Plays a stone at point, already known legal: captures whatever it takes, sets a fresh ko point when that capture was exactly one stone (and clears it otherwise), and passes the turn — Go has no further move of its own to settle, unlike the twist games or a piece game's line.

scoreAreafunction

The area score: every stone on the board, plus every empty region whose only neighbours are one colour.

walledInfunction

The empty points stone has already walled in: every empty region whose border is that colour's stones and nothing else — the ground scoreArea counts as theirs.

@johnmorrisdotca/narabe

ALL_BOARD_SIZESconstant

Every size any game here is played on, for the schemas at the API edge.

availableOpeningsfunction

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.

Blockedtype

An intersection the rules have taken out of play.

BLOCKEDconstant

The unavailable-cell marker.

BOARD_GRIDSconstant

Where a game's stones sit when it is drawn its own way: on the crossings, or in the squares.

BoardGridtype

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.

boardSizesForfunction

The board sizes a variant plays on, smallest first — the order they are drawn in.

BRAZILIAN_DRAUGHTS_RULESconstant

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.

campOffunction

Whose home camp point lies in, or null for the open board.

campSizefunction

Pieces a side has on size: the squares of its camp.

campSquaresfunction

The squares of a colour's home camp.

CANADIAN_CHECKERS_RULESconstant

Canadian checkers: the international rules on 12×12, thirty men a side in five rows.

canBeDrawnfunction

Whether this game can be drawn at all.

canChooseColourfunction

Whether the game is waiting on a seat to pick a colour.

canExtendOpeningfunction

Swap2 only: the first chooser may add two stones and pass the choice back.

canForfeitfunction

Whether a recorded forfeit could have been written here: only where the clock had no pass to write instead.

canGrowBoardfunction

Whether resizing is enabled and a larger native board is available.

canPassfunction

Whether passing is on offer: forced in a piece game with nothing to lay, free at any point in Go.

canShrinkBoardfunction

Whether resizing is enabled and a smaller native board is available.

canSkipfunction

Whether skipping is enabled and a legal corner stone can burn the turn.

canSwapSeatsfunction

Whether the seat to play may trade seats right now.

canTwistfunction

Whether the colour to move owes a quarter turn before the move is complete.

canUndofunction

Whether undo is enabled and a recorded move can be removed.

CAPTURE_CHOICESconstant

The free-choice and maximum-capture draughts modes.

CaptureChoicetype

Which capture a checkers-family player may choose, when more than one is on offer.

capturePathsfunction

The squares each capture has passed through so far, move by move, or null for a move that took nothing.

Celltype

One intersection of the board: a stone, an obstacle, a hotspot, a wormhole, or nothing.

cellAtfunction

Read a cell from a valid zero-based board point; null means empty.

checkersHasCapturefunction

Whether any of stone's pieces on the board has a capture available right now.

CheckersRulestype

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.

ColourRulestype

The rules one colour actually plays under: the variant's spec for that colour with the handicap laid over it.

COLUMN_LETTERSconstant

Column letters used in coordinate labels, left to right.

columnLetterfunction

Column letter, left to right: A, B, C ...

createGamefunction

Create an initial immutable position from native settings and an opening roll.

CrownMidCapturetype

What becomes of a man that reaches the far row in the middle of a capture.

DEFAULT_SETTINGSconstant

The defaults used when creating a game without overrides.

defaultBoardForfunction

The board a game OPENS on, where nothing else has said: its own defaultBoard if it has one, else the first of its boards.

DIRECTIONSconstant

The four line orientations through a point.

discCountfunction

Count black and white discs currently on a board.

DRAW_LIMITSconstant

The shares of the board a game may be called a draw at.

DrawLimittype

When a game nobody has won is called a draw.

drawnByLengthfunction

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.

dropTargetfunction

Where a stone dropped into col lands, or null when the column is full.

emptyPointsfunction

Every intersection still open: no stone, no obstacle.

endedWithNoMovesfunction

Whether the game ended because neither side had a move: two forced passes, the last two moves on the record.

EndgameCounttype

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.

EndgameCountKindtype

The two shapes an endgame count is written in — see EndgameCount.

endsOnItsOwnfunction

Whether the rules alone guarantee this game ends.

ENGLISH_CHECKERS_RULESconstant

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.

extendOpeningfunction

The chooser declines to choose and lays two more stones instead.

findWinningLinefunction

The winning line through point, if the stone there completes one under the rule that applies to its colour.

FIRST_PLAYERSconstant

The supported opening colours and random opener choice.

FIRST_STONEconstant

Black opens unless the settings say otherwise.

flipsAtfunction

The discs a stone of stone at point would turn.

footprintAtfunction

The absolute cells of an orientation anchored with its origin at anchor.

footprintFitsfunction

Whether every cell of a footprint is on the board and empty.

forbiddenAtfunction

Why stone may not play point, or null when it may.

forbiddenPointsfunction

Every empty point the colour to move is forbidden from playing right now.

forbiddenReasonfunction

Why the colour to move may not play point, when a forbidden shape is why.

forfeitOnRecordfunction

A missed turn, as the position the record will replay it to.

forfeitTurnfunction

Takes the turn away from the colour to move without a stone: the graceful penalty for a missed deadline.

GAME_STATUSconstant

The playing, won and drawn outcome labels.

GameSettingstype

Native rule, layout, opening, handicap and optional action settings.

GameStatetype

The complete immutable position and its move history, seats and outcome.

GameStatustype

Whether the game is playing, won or drawn.

groupAtfunction

The connected group of stones sharing the colour at from, and the empty points touching any of them — its liberties.

growBoardfunction

Returns the game on a larger board, or the state unchanged when it cannot grow.

Handicaptype

Extra restrictions one colour plays under, so a stronger player can give a weaker one a fair game.

HANDICAP_RULESconstant

The handicap toggles, in the order the settings list them.

HandicapRuletype

The toggles of a handicap, without the colour that carries them.

HandicapTermstype

EVERYTHING THAT MAKES A GAME UNEVEN ON PURPOSE, as hasHandicap reads it: the per-colour handicap and the head start.

hasFlipMovefunction

Whether the colour has a legal disc-flipping move.

hasHandicapfunction

Whether any handicap is in force for anyone: harder rules for one colour, or a head start for one.

HeadStarttype

A start given to one colour — the weaker player's — before the game is even.

HeadStartTurnstype

The most free turns a game offers as a head start: 0 where it offers none.

HEX_LINE_DIRECTIONSconstant

The three line orientations on the hexagon lattice — see rules/hexagon.ts for the embedding.

Hottype

A hotspot: an intersection that counts as either colour's stone in a line.

HOTconstant

The cell marker that counts as either colour in a line.

indexOffunction

Convert a board point into its row-major array index.

inLayingPhasefunction

Classic reversi: the first four discs are laid by the players, in the centre, with no flipping.

inMovePhasefunction

Whether the colour to move has all its pieces down and must now slide one.

isDarkSquarefunction

Checkers is played on one colour of square only: the board's own dark squares.

isKingAtfunction

Whether the piece at at, if any, is a king.

isLegalMovefunction

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.

isOnBoardfunction

Whether both coordinates are within the square board.

isStonefunction

Narrows a cell to a played stone, excluding empties and obstacles.

KOMIconstant

Go: stones never move once played, and nothing about a line ever decides anything.

landingPointsfunction

The one landing cell per column with room: the only cells a drop can fill.

lastMovefunction

The point of the latest stone or piece move; null when no point was played.

leavesNoStonefunction

Whether a recorded move put nothing on the board: a pass, or a turn the clock took away.

legalPointsfunction

Every intersection the colour to move may play right now.

LINE_RULESconstant

The at-least, exact and open-exact winning line modes.

lineDirectionsForfunction

The directions a winning line may run: the hexagon's three axes on a hexagon board, the square's four otherwise.

LineRuletype

What a completed line has to look like to win.

longestPossibleGamefunction

The most moves a game of these settings can contain, or null when nothing in the rules bounds it.

Movetype

A move rebuilt by the engine, including captures and other replay effects.

MOVE_KINDSconstant

The stable labels used in move records.

MoveInputtype

The shape of a move as a record or a request carries it, without the colour.

MoveNarrowingtype

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.

movePiecefunction

Slides a piece one step, or in checkers a step or a capture.

MoverRulestype

Which of the moving games' rules a game plays by (rules/movers.ts).

movesBeforeDrawfunction

How many moves may be played before a game nobody has won is a draw, or null when it is to be played out.

mustPassfunction

Whether the colour to move has nothing it may play.

nextBoardSizefunction

The next size up, or null when the board is already the largest.

NO_HANDICAPconstant

The default terms with no colour-bound rule restrictions.

NO_HEAD_STARTconstant

Nobody given a start: the even game, which is most games.

NO_POINTconstant

A pass has no point on the board.

noBoundReasonfunction

What stops this game being bounded by its board, or null when nothing does.

NoBoundReasontype

Why a game has no bound, or null when the board is its bound.

normaliseSettingsfunction

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.

OPENING_RULESconstant

The stable identifiers for supported opening protocols.

OpeningChoicetype

A decision taken during the opening: a colour, or two more stones.

OpeningStatetype

The opening protocol stage, acting seat and recorded colour choices.

orientationsfunction

Every distinct way the piece can lie: four rotations, each also mirrored.

orientCellsfunction

The piece turned turns quarter turns and, if asked, mirrored — the shape a player has in hand.

passesOwedfunction

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.

passTurnfunction

Takes a turn without a stone.

Piecetype

A piece from the queue: its cells relative to the top-left of its bounding box.

PIECE_PREVIEWconstant

How many queued pieces a player is shown ahead of the one in hand.

PIECE_QUEUESconstant

The domino and tetromino queue identifiers.

PieceCelltype

One cell of a multi-cell piece, with the colour it carries.

pieceMovesfunction

Where a piece of the colour to move may step from from; empty if it may not move.

PieceQueuetype

Which queue of pieces a game draws from.

piecesHomefunction

How many of stone's pieces stand in the far camp.

PieceTallytype

A side's pieces, as an endgame count names them.

Placementtype

Where a stone goes when played.

PLACEMENTSconstant

The free, dropped and supported-edge placement modes.

placePiecefunction

Lays the piece in hand on cells.

playMovefunction

Plays the stone to move at point.

Pointtype

Zero-based board coordinates.

pointNamefunction

Renju-style name for an intersection, e.g.

pointOffunction

Convert a row-major array index into board coordinates.

POOL_CHECKERS_RULESconstant

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).

previousBoardSizefunction

The next size down, or null when the board is already the smallest.

quadrantCountfunction

How many quadrants a board of this size holds.

queuedPiecefunction

The piece the colour to move must lay next, or null outside the piece games.

ReplayFactstype

What a replay needs to know about a record that its moves cannot say.

replayMovesfunction

Replays a record through the engine: every position it passed through, including the ones a swap-opening decision produced.

replayTimelinefunction

Rebuilds every position a game passed through by replaying its moves.

resignfunction

Gives the game up.

resolvePlacementfunction

Where a stone played at point actually goes: the same point, or in a drop game the bottom of its column.

rowNumberfunction

Row number counted from the bottom edge, so the bottom row is 1.

RULE_VARIANT_LISTconstant

The variants in the order the browser and the filters list them.

RULE_VARIANTSconstant

The stable identifiers for all fifty-two rule variants.

rulesForfunction

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.

RUSSIAN_DRAUGHTS_RULESconstant

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).

scoreAreafunction

The area score: every stone on the board, plus every empty region whose only neighbours are one colour.

Seattype

The two people at the board.

seatOffunction

The seat holding stone right now.

SEATSconstant

The first and second player seat labels.

SEED_RANGEconstant

Seeds are 31-bit integers, small enough for every store and reproducible everywhere.

seededRandomfunction

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.

shrinkBoardfunction

Returns the game on a smaller board, or the state unchanged when the ring that would be removed is in use.

singlesLeftfunction

Single stones the colour to move may still lay instead of a piece.

sizeForVariantfunction

The board this variant will actually be played on, given a size somebody asked for.

skipMovefunction

Burns the turn on a corner stone.

skipTargetfunction

Where a skipped turn puts its stone: the open intersection furthest from the action, picked from the corner chosen by roll.

SlideMovetype

What a record needs of a move to say whether it slid, jumped, or went on jumping.

slideWordfunction

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_POINTSconstant

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_RADIUSconstant

How many rows deep each of the star's six points is.

starCampOffunction

Whose home point point lies in, or null outside both.

starCampSizefunction

Pieces a side has: the cells of one point, ten on the standard board.

starPiecesHomefunction

How many of stone's pieces stand in the far point.

starSizefunction

The side of the square array a star of this radius is embedded in.

STARTING_DISCSconstant

The fixed, laid or absent starting-disc layouts.

StartingDiscstype

How a flipping game begins: nothing, the fixed four, or four the players lay themselves.

Stonetype

One of the two stone colours.

STONELESS_WORDSconstant

How a written move list says the two moves that have no point.

stonelessWordfunction

How a written record says a move with no point, or null for a move that has one.

STONESconstant

The black and white stone labels.

stonesLeftfunction

Stones the colour to move still has to place before the turn passes.

StoredGametype

The stored shape of a game, as both the API and the pages see it.

swapSeatsfunction

Trades seats: the player to move hands over their colour and takes the opponent's stones instead.

TraditionalHeadStarttype

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.

TurnChoiceKindtype

Whether a turn moves a piece already on the board, or places on a point.

turnChoicesfunction

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.

TurnChoicestype

What the colour to move may do this turn, as the engine answers it — see turnChoices.

turnPassedByfunction

The colour whose turn passed because it had no move, as the latest turn left the board — or null when nobody's did.

Twisttype

A quarter turn of one quadrant, which ends a move in the twist games.

twistBoardfunction

Turns one quadrant to finish the move.

undoMovefunction

Removes the last move, putting back anything it captured, a piece where it came from, and a twisted quadrant the way it was.

upcomingPiecesfunction

The pieces after the one in hand, for the preview.

WIN_LENGTHconstant

Stones in a line needed to win, unless a variant pins it.

WIN_LENGTHSconstant

Line lengths a player may pick in the variants that leave it open.

WIN_REASONSconstant

The recorded reasons a game is won.

winOnTimefunction

Ends the game against a player who has run out of time.

Wormtype

A wormhole: a line entering it comes out of its partner and carries on.

WORMconstant

The linked wormhole-cell marker.

WRAP_MODESconstant

The supported board edge-wrapping modes.

WrapModetype

Which edges of the board join up: a plane, a cylinder, or a torus.