Reference · Rules, games and records
applyMovefunction
The position after a move. Does not check that the move is legal.
Import it
import { applyMove } from "@johnmorrisdotca/sugoroku";
Definition
function applyMove(spec: VariantSpec, position: Position, side: Side, move: Move): Position
Parameters
| Name | Type | Description |
|---|---|---|
spec | VariantSpec | The native variant specification. |
position | Position | The native checker counts, bar, reserve and borne-off counts. |
side | Side | The side being examined: white or black. |
move | Move | A native legal move, including die and hit status. |
Returns
Position
The position after a move. Does not check that the move is legal.
Examples
import { applyMove, legalPlaysOf, newGame, rollOpening, settingsFor, startPosition } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const spec = settings.variant;
const position = startPosition(spec);
const game = rollOpening(newGame(settings),[3,1]);
const play = legalPlaysOf(game)[0];
const move = play.moves[0];
console.log(applyMove(spec,position,"white",move).bar);[ 0, 0 ]What it prints (run when this page was built)