Reference · Rules, games and records
undoMovefunction
Take back the last move made this turn. Does nothing if none has been made.
Import it
import { undoMove } from "@johnmorrisdotca/sugoroku";
Definition
function undoMove(game: GameState): GameState
Parameters
| Name | Type | Description |
|---|---|---|
game | GameState | The current immutable native game state. |
Returns
GameState
Take back the last move made this turn. Does nothing if none has been made.
Examples
import { legalPlaysOf, newGame, playMove, rollOpening, settingsFor, undoMove } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const play = legalPlaysOf(game)[0];
const move = play.moves[0];
console.log(undoMove(playMove(game,move)).moves.length);0What it prints (run when this page was built)