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

positionFromIdfunction

The position an ID stands for, with onRoll to move, or null if the text is not an ID. The ID does not say how many checkers each side began with: pass the variant's (15 for the standard board), and what is not on the board is counted as borne off.

Import it

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

Definition

function positionFromId(id: string, onRoll: Side, checkers?: number): Position | null

Parameters

NameTypeDescription
idstring

A GNU-compatible position ID.

onRollSide

The side to roll, or whether this evaluated side is on roll, specified by the signature.

checkers (optional)number

The checker count expected for each side.

Returns

Position | null

The position an ID stands for, with onRoll to move, or null if the text is not an ID. The ID does not say how many checkers each side began with: pass the variant's (15 for the standard board), and what is not on the board is counted as borne off.

Examples

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

const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
console.log(positionFromId(positionId(position,"white")!,"white")?.bar);
[ 0, 0 ]

What it prints (run when this page was built)

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