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

How-to

Handle the cube and match score

Offer, take or drop only in the allowed phase.

A cube decision before rolling

import {settingsFor,newGame,rollOpening,legalPlaysOf,playTurn,canDouble,offerDouble,takeDouble,newMatch,pointsToGo} from "@johnmorrisdotca/sugoroku";
const settings = settingsFor("backgammon",{points:5,cube:true});
const opened = rollOpening(newGame(settings),[3,1]);
const game = playTurn(opened,legalPlaysOf(opened)[0].moves);
console.log(canDouble(game),takeDouble(offerDouble(game)).cube);
console.log(pointsToGo(newMatch(settings),"white"));
true { value: 2, owner: 'white' }
5

A double is offered before rolling by the eligible cube owner, or either side while centred. Taking doubles the cube and transfers ownership; dropping ends at the old value. A beaver needs its rule enabled and an offered double, and has its own response phase. Consult canDouble/canBeaver rather than guessing from the displayed value.

Record one result once

newMatch keeps scores, results and Crawford bookkeeping; startGame inherits the current score and cube-free Crawford flag. Feed the completed GameResult once to finishGame. A match ends at its point target, while points 0 keeps the score without a target. Single, gammon and backgammon multipliers respect configured rules. The dead cube and Crawford restrictions are native decisions. See finishGame and record validation.

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