Reference · Rules, games and records
withCountsfunction
A copy of a position with some counts changed.
Import it
import { withCounts } from "@johnmorrisdotca/sugoroku";
Definition
function withCounts(position: Position, changes: { points?: [number[], number[]]; bar?: [number, number]; reserve?: [number, number]; off?: [number, number]; }): Position
Parameters
| Name | Type | Description |
|---|---|---|
position | Position | The native checker counts, bar, reserve and borne-off counts. |
changes | { points?: [number[], number[]]; bar?: [number, number]; reserve?: [number, number]; off?: [number, number]; } | The replacement checker-count fields. |
Returns
Position
A copy of a position with some counts changed.
Examples
import { settingsFor, startPosition, withCounts } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
console.log(withCounts(position,{off:[0,0]}).off);[ 0, 0 ]What it prints (run when this page was built)