Reference
Tiles, Mexican Train and replay
import { … } from "@johnmorrisdotca/domino";
9.9 kB minified and gzipped, with everything it imports (measured with esbuild)
Domino: double-nine, double-twelve and double-fifteen sets of dominoes, and Mexican Train with a computer player and a saved-game format.
Exports
| Name | Kind | What it is |
|---|---|---|
cleanTrainName | function | A seat's name as given, its spaces tidied and cut to TRAIN_NAME_MOST characters. |
CLI_MOVES_MOST | constant | The most moves a played game may take before the command line gives up, far above any game the rules allow. |
cliLanguage | function | The language the command line speaks: --lang, or the environment's, or the system's; Japanese for ja…, English for anything else. |
CliResult | type | What the command line came to. |
CliSurroundings | type | What the command line is run in. |
computerMove | function | The move the computer in the seat to move makes now: the best-scored lay, or the draw, pass or next round it must take. |
decodeTrain | function | A kept game read back, or null for nothing kept or anything these rules cannot play out again. |
Domino | type | A domino in a hand or the boneyard: low * 16 + high. |
DOMINO_STRINGS | constant | Every string, in both languages. |
dominoLanguage | function | The language a person asked for, by en or ja or a tag that begins with one: English for anything else. |
dominoSay | function | A string with its braces filled in from values; a brace with no value is left as it is. |
DominoStrings | type | The names of the strings. |
DoublesRule | type | How a double is dealt with, the table's one house rule about them. |
encodeTrain | function | Serialize setup and recorded legal moves so the same seeded game can be replayed. |
endsOf | function | A tile's two ends, the smaller first. |
everyTile | function | Every tile of a set, double-blank to its highest double, in order. |
fits | function | Whether a tile has this number at either end, so it can be laid against it. |
handPips | function | The pips in a hand, which count against its holder when the round ends. |
handSizeFor | function | HOW MANY TILES EACH PLAYER IS DEALT, by the set and the number at the table. |
isDouble | function | Both ends the same: a double, which is laid across a train and must be covered. |
laidAgainst | function | The tile laid against end: turned so that end touches, the other one left open. |
LaidDomino | type | A domino laid in a train, turned so its from end touches the train: from * 16 + to. |
laidEnds | function | A laid tile's two ends in the order it lies: the one touching the train, then the open one. |
Language | type | The languages Domino speaks. |
legalPlays | function | Every tile the player to move may lay, and where: what moves offers, and what the table lights up. |
longestRun | function | The longest run of tiles from hand that can be laid one after another against end, in the order they would be laid. |
mayLay | function | Whether the player to move may lay this tile on this train now: the same answer legalPlays gives, for one tile, without listing every other. |
mexicanOf | function | The Mexican Train's number among a game's trains: after every seat's own. |
MexicanStart | type | When the Mexican Train may be started. |
moveCount | function | How many moves a game has made. |
movesOf | function | Every move a game has made, first to last. |
openEnd | function | The number a train's next tile must match: its last tile's open end, or the engine double's when nothing is laid on it yet. |
peopleAt | function | The seats a person plays: a table with two or more of them passes the device, and covers each hand between turns. |
pipsOf | function | Every pip on a tile: what it counts against its holder when a round ends. |
playTrain | function | The game after that move, or null for a move that may not be made now. |
Random | type | A number in [0, 1), like Math.random, from a stream a seed fixes. |
replayTrain | function | A game played again from its table and its moves: what reading a kept game back does. |
RoundEnding | type | Why a round ended: somebody played their last tile, or nobody could play and nothing was left to draw. |
RoundResult | type | A round's result, kept for the table of scores. |
roundsFor | function | How many rounds a game of this length plays with this set: one per double, top to blank, or the first half of them. |
runCli | function | Run the command line. |
seededRandom | function | A stream of numbers in [0, 1) fixed by a seed. |
shuffled | function | A copy of the list in a random order (Fisher–Yates); the list given is left alone. |
startTrain | function | A new game: the set (its highest double), the names at the table (one a seat), which seats a computer plays, the options, and the seed every shuffle is drawn from. |
tileOf | function | The tile with these two ends, whichever order they are given in. |
tileOfLaid | function | The tile a laid tile is, whichever way round it lies. |
tileWords | function | A tile as a person reads it: "6–4", the larger end first, as a tile is named at the table. |
Train | type | A train on the table: the tiles laid on it in order, and whether its owner's marker says anybody may play on it. |
TRAIN_DEFAULT_OPTIONS | constant | The options a table opens on: every round, one double at a time, and the Mexican Train open from the start. |
TRAIN_DOUBLES | constant | The one-double and chained-double house-rule choices. |
TRAIN_LENGTHS | constant | The full and short round-count choices for a game. |
TRAIN_MEXICAN | constant | The unrestricted and own-train-first Mexican Train opening choices. |
TRAIN_NAME_MOST | constant | The longest name a seat keeps. |
TRAIN_PHASES | constant | MEXICAN TRAIN, THE DOMINO GAME: the rules, and nothing else. |
TRAIN_PIP_BASE | constant | The largest set's highest double, and so the base a tile's two ends are written in (tileOf). |
TRAIN_SET_NAMES | constant | Each set by name, for the set-up's tiles and the card on My games. |
TRAIN_SETS | constant | THE SETS OFFERED, by their highest double. |
trainAgain | function | The same table again, the same seats and options, with a fresh shuffle. |
TrainGame | type | A game, as its table and moves make it. |
TrainHistory | type | One link of a game's record: a move, and every move before it. |
TrainLength | type | How many rounds: all of them, one for every double from the set's highest down to double blank, or half as many. |
TrainMove | type | One move at the table. |
trainMoves | function | Every move the player to move may make now; none once the game is over. |
trainName | function | A train's name: "Your train", "Computer 2's train", or the Mexican Train. |
trainNews | function | What the last move did, in a line, or "" before there is one: "Computer 2 laid 9–4 on Your train." |
TrainOptions | type | What the set-up chose, beyond the set and the players. |
TrainPhase | type | Whether the game is playing, awaiting the next round, or finished. |
trainPlayerName | function | A seat's name as the table reads it: the one given, or "Computer 3" for a computer's seat left blank, "Player 3" for a person's. |
TrainSeat | type | Who sits where: 0 is the first player, round the table in the order the set-up named them. |
trainSeatName | function | A seat's name: the one given at the table, or "You" for the person at this device, or "Computer 3" or "Player 3" for the seat's number. |
trainSetLabel | function | The set's name by its highest double ("Double-twelve"), or null for a number that is no set offered. |
trainSetName | function | The set's name, or null for a number that is no set offered. |
trainStatus | function | What is going on, in a line: who is to play, or what the person at you is asked to do (lay, cover a double, draw, pass), or how the round or the game ended. |
trainTotals | function | Each seat's total over every round played: the lowest wins. |
VERSION | constant | The package's version. |