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 · Playable board

SugorokuEventDetailtype

What every event of the board carries.

Import it

import type { SugorokuEventDetail } from "@johnmorrisdotca/sugoroku/play";

Definition

type SugorokuEventDetail = {
    side: Side | null;
    game: GameState;
    match: Match;
    dice?: readonly number[];
    notation?: string;
    move?: Move;
    moves?: readonly Move[];
    action?: "double" | "take" | "drop" | "beaver";
    result?: GameResult;
    record?: string;
};

Members

NameTypeDescription
sideSide | null

The side it is about; null for the opening throw.

gameGameState
matchMatch
dice (optional)readonly number[] | undefined

Dice: for a roll, those rolled; for a turn, the roll played.

notation (optional)string | undefined

A move in standard notation, or a turn's play.

move (optional)Move | undefined
moves (optional)readonly Move[] | undefined
action (optional)"double" | "take" | "drop" | "beaver" | undefined

What was done to the cube.

result (optional)GameResult | undefined

The result, for sugoroku-end.

record (optional)string | undefined

The record of the match so far, for sugoroku-end.

Examples

import { newGame, newMatch, rollOpening, settingsFor } from "@johnmorrisdotca/sugoroku";
import type { SugorokuEventDetail } from "@johnmorrisdotca/sugoroku/play";

const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const match = newMatch(settings);
const value: SugorokuEventDetail = {side:"white",game,match,dice:[3,1]};
console.log(value);
{
  side: 'white',
  game: {
    settings: { variant: [Object], rules: [Object] },
    crawford: false,
    score: [ 0, 0 ],
    position: { points: [Array], bar: [Array], reserve: [Array], off: [Array] },
    turn: 'white',
    phase: 'playing',
    dice: [ 3, 1 ],
    need: [ 3, 1 ],
    plan: [ 3, 1 ],
    moves: [],
    turnStart: { points: [Array], bar: [Array], reserve: [Array], off: [Array] },
    cube: { value: 1, owner: null },
    offeredBy: null,
    turns: [ 0, 0 ],
    opening: [ 3, 1 ],
    result: null
  },
  match: {
    settings: { variant: [Object], rules: [Object] },
    score: [ 0, 0 ],
    results: [],
    crawfordNext: false,
    crawfordPlayed: false,
    over: false,
    winner: null
  },
  dice: [ 3, 1 ]
}

What it prints (run when this page was built)

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