本文へ移動

Dominoドミノ

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

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

目次

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

longestRun関数

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

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 { longestRun } from "@johnmorrisdotca/domino";

定義

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

引数

名前型説明
handreadonly number[]

The canonical tile numbers in one hand.

endnumber

The pip value the next laid tile must match.

戻り値

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.

例

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

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

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

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

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