Reference · Rules, games and records
Strengthtype
THE COMPUTER PLAYER, in four strengths. Each is the one before it with more care, and none of them is slow: a move takes a few milliseconds, and the strongest well under a tenth of a second in a browser.
random: any legal play, with equal chance. It never doubles, and takes every double.greedy: the play that leaves the best position by the evaluation (evaluate), looking no further.careful: weighs its best four plays by what the other side's best reply to each roll would leave.strong: the same over its best ten plays.
Doubling is simple, and works as documented in the README: in a race the
Keith count (see keithCount), where the rules are Keith's: double when the
count of the side on roll is within 4 of the other's, redouble within 3,
take when the doubler's is 2 or more above the taker's. In a position where the sides are still in
contact (careful and strong only), the evaluation is turned into a
chance of winning (winChance) and a side doubles at 70% and takes at 25%.
Import it
import type { Strength } from "@johnmorrisdotca/sugoroku";
Definition
type Strength = "random" | "greedy" | "careful" | "strong";
Examples
import type { Strength } from "@johnmorrisdotca/sugoroku";
const value: Strength = "greedy";
console.log(value);greedyWhat it prints (run when this page was built)