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
| Name | Type | Description |
|---|---|---|
id | string | A GNU-compatible position ID. |
onRoll | Side | 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)