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

Reference · Tiles, Mexican Train and replay

replayTrainfunction

A game played again from its table and its moves: what reading a kept game back does. Null if any move is one the rules would not have taken.

Import it

import { replayTrain } from "@johnmorrisdotca/domino";

Definition

function replayTrain(set: number, players: readonly string[], seed: number, options: TrainOptions, computers: readonly boolean[], moves: readonly TrainMove[]): TrainGame | null

Parameters

NameTypeDescription
setnumber

The highest double of the supported set: 9, 12 or 15.

playersreadonly string[]

Player count, or names in seat order, as specified by this signature.

seednumber

The seed for reproducible shuffles.

optionsTrainOptions

Native sound-player choices or Mexican Train house rules specified by the signature.

computersreadonly boolean[]

Which seats are computer-controlled, in player order.

movesreadonly TrainMove[]

Recorded native moves in chronological order.

Returns

TrainGame | null

A game played again from its table and its moves: what reading a kept game back does. null if any move is one the rules would not have taken.

Examples

import { movesOf, playTrain, replayTrain, startTrain, trainMoves } from "@johnmorrisdotca/domino";

const game = startTrain(9,["A","B"],42,{length:"short",doubles:"one",mexican:"any"},[false,true])!;
const moved = playTrain(game,trainMoves(game)[0])!;
console.log(replayTrain(game.set,game.players,game.seed,game.options,game.computers,movesOf(moved))?.turn);
1

What it prints (run when this page was built)

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