Reference · Rules, games and records
stepComputerfunction
Carry out one step of what the computer would do, with dice from dice.
Returns the game after it, and what was done, so a caller can write it down
or show it. Which side plays is up to the caller: this plays for whichever side is to act.
Import it
import { stepComputer } from "@johnmorrisdotca/sugoroku";
Definition
function stepComputer(game: GameState, dice: DiceSource, options?: ComputerOptions): { game: GameState; action: ComputerAction; } | null
Parameters
| Name | Type | Description |
|---|---|---|
game | GameState | The current immutable native game state. |
dice | DiceSource | Dice values as thrown, or a reproducible source specified by the signature. |
options (optional) | ComputerOptions | Native drawing, geometry, mounting or computer choices specified by the signature. |
Returns
{ game: GameState; action: ComputerAction; } | null
The next state and selected computer action, or null when no action remains.
Examples
import { newGame, rollOpening, seededDice, seededRandom, settingsFor, stepComputer } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
console.log(stepComputer(game,seededDice(42),{strength:"greedy",random:seededRandom(42)})?.game.phase);before-rollWhat it prints (run when this page was built)