Skip to the content

Narabe並べ

Play forty-eight abstract board games through immutable moves, legal choices and replayable records.

Narabe means arranging in Japanese, as in gomoku-narabe: five in a row. About the name

Contents

Reference · Rules and records

GameStatetype

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

Import it

import type { GameState } from "@johnmorrisdotca/narabe";

Definition

type GameState = {
    settings: GameSettings;
    board: Cell[];
    moves: Move[];
    opener: Stone;
    seats: Record<Stone, Seat>;
    swapsUsed: Record<Seat, number>;
    captures: Record<Stone, number>;
    opening: OpeningState;
    toPlay: Stone;
    pendingTwist: boolean;
    kings: readonly Point[];
    chainAt: Point | null;
    koPoint: Point | null;
    status: GameStatus;
    winner: Stone | null;
    winBy: WinReason | null;
    winningLine: Point[];
};

Members

NameTypeDescription
settingsGameSettings
boardCell[]

Row-major, size * size entries. See indexOf / pointOf.

movesMove[]

Every move played so far, in order.

openerStone

The colour that opened, kept so the game can be replayed from move zero.

seatsRecord<Stone, Seat>

Which seat currently holds each colour. Exchanged by swapSeats.

swapsUsedRecord<Seat, number>

Swaps each seat has spent, counted against settings.swapsPerSeat.

capturesRecord<Stone, number>

Pairs each colour has captured. Always zero outside the capture variants.

openingOpeningState
toPlayStone
pendingTwistboolean

True between placing a stone and turning a quadrant, in the twist games.

kingsreadonly Point[]

Board squares holding a crowned piece, in the checkers family. Empty everywhere else.

chainAtPoint | null

The square of a piece mid-capture-chain that must keep jumping, in the checkers family. Null otherwise.

koPointPoint | null

The point the simple ko rule forbids retaking this move, in Go. Null otherwise.

statusGameStatus
winnerStone | null
winByWinReason | null
winningLinePoint[]

The stones that completed the winning line, empty until someone wins.

Examples

import { createGame, playMove } from "@johnmorrisdotca/narabe";
import type { GameState } from "@johnmorrisdotca/narabe";

const state = createGame({variant:"freestyle",size:15});
const point = {row:7,col:7};
const value: GameState = playMove(state,point);
console.log(value);
{
  settings: {
    size: 15,
    winLength: 5,
    variant: 'freestyle',
    opening: 'free',
    handicap: {
      stone: null,
      doubleThree: false,
      doubleFour: false,
      overline: false,
      exactLine: false,
      openLine: false,
      longerLine: false,
      singleStone: false,
      noCaptures: false,
      secondStoneExclusion: 0
    },
    headStart: { stone: null, freeTurns: 0, traditional: 0 },
    seed: 0,
    capturesToWin: 10,
    firstPlayer: 'black',
    obstacles: 'none',
    allowUndo: true,
    allowSkip: false,
    allowSwap: false,
    allowResize: false,
    swapsPerSeat: 1,
    drawLimit: 'none'
  },
  board: [
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    null, null, null, null, null, null, null, null, null, null,
    ... 125 more items
  ],
  moves: [ { row: 7, col: 7, stone: 'black', kind: 'place' } ],
  opener: 'black',
  seats: { black: 'one', white: 'two' },
  swapsUsed: { one: 0, two: 0 },
  captures: { black: 0, white: 0 },
  opening: { stage: 'done', actor: null, choices: [] },
  toPlay: 'white',
  pendingTwist: false,
  kings: [],
  chainAt: null,
  koPoint: null,
  status: 'playing',
  winner: null,
  winBy: null,
  winningLine: []
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/narabe 1.3.0.