Skip to the content

Sugoroku双六

Play backgammon and its relatives with native rules, cube and match scoring, seeded dice and replayable records.

Sugoroku is the Japanese name 双六 for games of tables. About the name

Contents

Reference · Rules, games and records

ReplayedGametype

One game of a replayed record, finished.

Import it

import type { ReplayedGame } from "@johnmorrisdotca/sugoroku";

Definition

type ReplayedGame = {
    readonly result: GameResult;
    readonly turns: readonly [
        number,
        number
    ];
    readonly position: Position;
};

Members

NameTypeDescription
resultGameResult
turnsreadonly [number, number]

The turns each side took.

positionPosition

The position the game ended in.

Examples

import { concede, newGame, rollOpening, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";
import type { ReplayedGame } from "@johnmorrisdotca/sugoroku";

const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
const game = rollOpening(newGame(settings),[3,1]);
const result = concede(game,"black","single").result!;
const value: ReplayedGame = {result,turns:[1,0],position};
console.log(value);
{
  result: {
    winner: 'white',
    how: 'concede',
    kind: 'single',
    multiplier: 1,
    cube: 1,
    points: 1
  },
  turns: [ 1, 0 ],
  position: {
    points: [ [Array], [Array] ],
    bar: [ 0, 0 ],
    reserve: [ 0, 0 ],
    off: [ 0, 0 ]
  }
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/sugoroku 1.1.1.