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

legalPlaysfunction

Every different turn a side may make with a roll: one for each position that playing the roll as the rules require can leave, with one way of getting there. A side that cannot move has the one play of no moves.

Import it

import { legalPlays } from "@johnmorrisdotca/sugoroku";

Definition

function legalPlays(spec: VariantSpec, position: Position, side: Side, roll: readonly number[]): Play[]

Parameters

NameTypeDescription
specVariantSpec

The native variant specification.

positionPosition

The native checker counts, bar, reserve and borne-off counts.

sideSide

The side being examined: white or black.

rollreadonly number[]

The valid dice as thrown, in throw order.

Returns

Play[]

Every different turn a side may make with a roll: one for each position that playing the roll as the rules require can leave, with one way of getting there. A side that cannot move has the one play of no moves.

Examples

import { legalPlays, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";

const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
console.log(legalPlays(spec,position,"white",[3,1]).length);
16

What it prints (run when this page was built)

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