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

Getting started

Getting started

Open a game and play one complete legal turn.

Pure state first

Install @johnmorrisdotca/sugoroku with npm. The root entry provides variants, rules, games, matches, dice and records without DOM. Drawing and mounting have separate entries.

import {settingsFor,newGame,rollOpening,legalPlaysOf,playTurn} from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const game = rollOpening(newGame(settings),[3,1]);
const play = legalPlaysOf(game)[0];
const next = playTurn(game,play.moves);
console.log(game.turn,next.turn,next.phase);
white black before-roll

White's higher opening die selects White; ordinary backgammon plays those two opening dice. playTurn applies a complete legal play and ends the turn. Keep the original state if you need to compare or undo host actions; rule functions return new values.

Next read legal turns, variants, cube/matches or native boards. Every public export has its own example in the root reference. Inputs from another engine should first be mapped to native numbering and variant rules.

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