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

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

NameTypeDescription
gameGameState

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)

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