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

longestRunfunction

The longest run of tiles from hand that can be laid one after another against end, in the order they would be laid. A depth-first search over the hand, bounded by PLAN_STEPS, preferring the heavier run of two the same length: pips laid are pips that do not count.

Import it

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

Definition

function longestRun(hand: readonly Domino[], end: number): Domino[]

Parameters

NameTypeDescription
handreadonly number[]

The canonical tile numbers in one hand.

endnumber

The pip value the next laid tile must match.

Returns

number[]

The longest run of tiles from hand that can be laid one after another against end, in the order they would be laid. A depth-first search over the hand, bounded by PLAN_STEPS, preferring the heavier run of two the same length: pips laid are pips that do not count.

Examples

import { longestRun, tileOf } from "@johnmorrisdotca/domino";

console.log(longestRun([tileOf(1,2),tileOf(2,3),tileOf(3,4)],1));
[ 18, 35, 52 ]

What it prints (run when this page was built)

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