Reference · Rules, games and records
computerActionfunction
What the side that has to act in a game would do, if the computer were playing it. Nothing is done: the game is not changed. Null when the game is over.
Import it
import { computerAction } from "@johnmorrisdotca/sugoroku";
Definition
function computerAction(game: GameState, options?: ComputerOptions): ComputerAction | null
Parameters
| Name | Type | Description |
|---|---|---|
game | GameState | The current immutable native game state. |
options (optional) | ComputerOptions | Native drawing, geometry, mounting or computer choices specified by the signature. |
Returns
ComputerAction | null
The phase-appropriate computer action, or null when the game is over.
Examples
import { computerAction, newGame, rollOpening, seededRandom, settingsFor } from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
console.log(computerAction(game,{strength:"greedy",random:seededRandom(42)}));{
kind: 'play',
play: {
moves: [ [Object], [Object] ],
position: { points: [Array], bar: [Array], reserve: [Array], off: [Array] }
}
}What it prints (run when this page was built)