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

canPlayAllfunction

Whether every die of need (highest first) can be played from position, in some order.

Import it

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

Definition

function canPlayAll(spec: VariantSpec, position: Position, side: Side, need: readonly number[], failed?: Set<string>): boolean

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.

needreadonly number[]

The dice remaining to play.

failed (optional)Set<string>

Optional failed-position cache for the recursive legal-play search.

Returns

boolean

Whether every die of need (highest first) can be played from position, in some order.

Examples

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

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

What it prints (run when this page was built)

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