Skip to the content

Sugoroku双六

Play backgammon and its relatives with native rules, cube and match scoring, seeded dice and replayable records.

Sugoroku is the Japanese name 双六 for games of tables. About the name

Contents

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

NameTypeDescription
gameGameState

The current immutable native game state.

diceDiceSource

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-roll

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/sugoroku 1.1.1.