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

TRAIN_PHASESconstant

MEXICAN TRAIN, THE DOMINO GAME: the rules, and nothing else.

Pure, as the engine is: every function returns a new game and leaves the one it was given untouched. A game is its table (the set, the options, the seed, the seats) and its moves, in order; hands, trains, the boneyard and whose turn it is are always read again from those (replayTrain), so a game read back out of a browser's storage is exactly the game its moves make, or none. Every shuffle is drawn from the game's seed and the round's number, so a reload deals exactly what it dealt before.

The rules as the site plays them, most published rules' own:

  • a round is dealt round the engine double, the set's highest in the first round and one fewer each round after, which sits in the hub;
  • every player has a train of their own out of the hub, and there is one more, the Mexican Train, anybody may play on;
  • on your turn lay one tile against the open end of your own train, the Mexican Train, or any player's train whose marker is out;
  • nothing to lay: draw one tile; lay it if it goes, or put your marker out and pass (with nothing to draw, just put it out); lay on your own train and your marker comes in;
  • a double must be covered before anything else is played anywhere, and whoever lays one lays again to cover it (DoublesRule for the house rule that lets doubles be chained);
  • a round ends when somebody lays their last tile, or when nobody can lay and there is nothing left to draw; every player scores the pips left in their hand, and after the last round the lowest total wins.

Import it

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

Definition

const TRAIN_PHASES: { readonly playing: "playing"; readonly roundOver: "roundOver"; readonly finished: "finished"; } = {
    playing: "playing",
    roundOver: "roundOver",
    finished: "finished",
} as const satisfies Record<TrainPhase, TrainPhase>

Members

NameTypeDescription
playing"playing"
roundOver"roundOver"
finished"finished"

Examples

import { TRAIN_PHASES } from "@johnmorrisdotca/domino";
console.log(TRAIN_PHASES);
{ playing: 'playing', roundOver: 'roundOver', finished: 'finished' }

What it prints (run when this page was built)

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