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

ComputerOptionstype

Strength, tie-breaking randomness, lookahead time budget and evaluation weights for computer decisions.

Import it

import type { ComputerOptions } from "@johnmorrisdotca/sugoroku";

Definition

type ComputerOptions = {
    strength?: Strength;
    random?: Random;
    budget?: number;
    weights?: EvaluationWeights;
};

Members

NameTypeDescription
strength (optional)Strength | undefined

The strength. Default strong.

random (optional)Random | undefined

Where its choices come from, for random and for choosing between plays that score the same. Default Math.random.

budget (optional)number | undefined

The longest, in milliseconds, it spends looking ahead at one move: it looks at its best plays in order and stops when the time is up (always having looked at the best two). Default 60, so a move stays well under a tenth of a second even in a position of hundreds of plays on a slow device. Infinity for a search that does not depend on how fast the machine is.

weights (optional)EvaluationWeights | undefined

Weights for the evaluation, to play with a different taste. Default EVALUATION_WEIGHTS.

Examples

import type { ComputerOptions } from "@johnmorrisdotca/sugoroku";
import { seededRandom } from "@johnmorrisdotca/sugoroku";

const value: ComputerOptions = {strength:"greedy",random:seededRandom(42)};
console.log(value);
{ strength: 'greedy', random: [Function (anonymous)] }

What it prints (run when this page was built)

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