Skip to the content

Dominoドミノ

Deal seeded dominoes, play Mexican Train with native rules and computers, and replay a saved game.

Domino is the Japanese borrowed word ドミノ for dominoes. About the name

Contents

Getting started

Getting started

Deal a seeded table and take one legal move.

Start from the rules

Install @johnmorrisdotca/domino with npm. Its root entry is plain data and pure functions, safe on a server and in a browser. A game needs a supported set, two to eight seats, a seed and optional house rules.

import {startTrain,trainMoves,playTrain,trainStatus} from "@johnmorrisdotca/domino";
const game = startTrain(9,["A","B"],42)!;
const move = trainMoves(game)[0];
const next = playTrain(game,move)!;
console.log(game.seed,game.hands.map(hand=>hand.length),move);
console.log(trainStatus(next,"en",0));
42 [ 10, 10 ] { kind: 'play', tile: 41, train: 0 }
B to play.

These assertions use valid fixed setup and a move supplied by the rules. For external setup or actions, branch on null. The original state stays untouched; render the returned state. A seed fixes the deal, while moves decide the game that follows.

Pick your next step

Legal plays and tile numbers explain the shared Mexican Train and doubles. Computer play supplies deterministic turns. Saving rebuilds the same game from its seed and record. There is a playable native demo and a CLI guide; the package does not supply a mounted custom element.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/domino 1.1.4.