本文へ移動

Dominoドミノ

シード付きでドミノを配り、標準のルールとコンピューターでメキシカントレインを遊び、保存したゲームを再生します。

「ドミノ」は、英語の domino をそのまま日本語に取り入れた言葉です。 名前について(英語)

目次

リファレンス · 牌・メキシカントレイン・再生

TrainGame型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

A game, as its table and moves make it. Only the set, the options, the seed, the seats and the moves are ever kept (encodeTrain); everything else is read again from them (replayTrain), so a kept game can never hold a hand or a train its moves do not make, and a reload cannot deal again.

インポート

import type { TrainGame } from "@johnmorrisdotca/domino";

定義

type TrainGame = {
    set: number;
    options: TrainOptions;
    seed: number;
    players: readonly string[];
    computers: readonly boolean[];
    history: TrainHistory | null;
    rounds: number;
    round: number;
    engine: number;
    hands: readonly (readonly Domino[])[];
    trains: readonly Train[];
    boneyard: readonly Domino[];
    toPlay: TrainSeat;
    uncovered: readonly number[];
    chaining: boolean;
    drew: boolean;
    passes: number;
    turn: number;
    phase: TrainPhase;
    results: readonly RoundResult[];
    winners: readonly TrainSeat[];
    last: {
        seat: TrainSeat;
        move: TrainMove;
    } | null;
};

メンバー

名前型説明
setnumber

The set, by its highest double: 9, 12 or 15. The party game's "board size".

optionsTrainOptions
seednumber

What every shuffle of this game is drawn from.

playersreadonly string[]

The names given at the table, in seat order: "" for one left blank.

computersreadonly boolean[]

Which seats a computer plays.

historyTrainHistory | null

Every move made, the last first, each pointing at the record before it: the game's whole record (movesOf reads it out in order). A chain rather than a list, so a move adds one link and copies nothing — a double-fifteen game runs to thousands of moves, and a list copied on every one of them is millions of copies a game.

roundsnumber

How many rounds this game plays, and which one is being played (0 for the first).

roundnumber
enginenumber

The engine double's number this round: the set's highest in the first, one fewer each round after.

handsreadonly (readonly number[])[]
trainsreadonly Train[]

Every seat's train, then the Mexican Train last.

boneyardreadonly number[]

The tiles still face down, in the order they will be drawn.

toPlaynumber
uncoveredreadonly number[]

Trains whose last tile is a double not yet covered, the last laid last: while any is open, the only play anywhere is to cover the last of them.

chainingboolean

The player to move laid a double this turn and may still lay another before covering (chain only).

drewboolean

The player to move has drawn this turn: the tile drawn must be played if it can, or they pass.

passesnumber

Turns passed in a row with nothing played: a whole table of them with the boneyard empty ends the round.

turnnumber

Counts every change of the player to move: a new number is a new turn, and a covered hand to pass on.

phaseTrainPhase
resultsreadonly RoundResult[]
winnersreadonly number[]

On a finished game, every seat with the lowest total.

last{ seat: TrainSeat; move: TrainMove; } | null

The last move played, for the line that says what just happened.

例

import { startTrain } from "@johnmorrisdotca/domino";
import type { TrainGame } from "@johnmorrisdotca/domino";

const game = startTrain(9,["A","B"],42,{length:"short",doubles:"one",mexican:"any"},[false,true])!;
const value: TrainGame = game;
console.log(value);
{
  set: 9,
  options: { length: 'short', doubles: 'one', mexican: 'any' },
  seed: 42,
  players: [ 'A', 'B' ],
  computers: [ false, true ],
  history: null,
  rounds: 5,
  round: 0,
  engine: 9,
  hands: [
    [
      21, 41, 86,  72, 73,
       3, 88, 70, 137, 56
    ],
    [
       0, 103,   2, 22,  1,
      40,  52, 105,  9, 24
    ]
  ],
  trains: [
    { laid: [], open: false },
    { laid: [], open: false },
    { laid: [], open: true }
  ],
  boneyard: [
    69, 87,  35,  68, 54, 18, 119, 25,  38,
    57, 20,  23, 136, 89,  7,  17, 53,  55,
     4, 51, 102,  71, 85, 36, 121,  8, 104,
    37, 34, 120,  39,  5,  6,  19
  ],
  toPlay: 0,
  uncovered: [],
  chaining: false,
  drew: false,
  passes: 0,
  turn: 0,
  phase: 'playing',
  results: [],
  winners: [],
  last: null
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/domino 1.1.4 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。