layPairs関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Lay these pairs of tiles into the slots present names, or null when no
attempt reached the end. Higher slots are a little likelier to be taken
first, which keeps the stacks coming down together and leaves fewer
attempts stuck on a tower of two.
インポート
import { layPairs } from "@johnmorrisdotca/jarajara";
定義
function layPairs(geometry: MahjongGeometry, present: readonly boolean[], pairs: readonly (readonly [string, string])[], random: Random): Laid | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
geometry | MahjongGeometry | The stacked layout’s covering and side-blocking relationships. |
present | readonly boolean[] | Whether each native slot is still occupied or selected for laying. |
pairs | readonly (readonly [string, string])[] | Matching tile-face pairs to lay into slots. |
random | Random | A reproducible random source returning values in [0,1). |
戻り値
Laid | null
Lay these pairs of tiles into the slots present names, or null when no attempt reached the end. Higher slots are a little likelier to be taken first, which keeps the stacks coming down together and leaves fewer attempts stuck on a tower of two.
例
import { generateAwase } from "@johnmorrisdotca/jarajara/awase";
import { geometryOf, layPairs, layoutFor, pairsLeft, seededRandom } from "@johnmorrisdotca/jarajara";
const deal = generateAwase(4,"easy",2026);
const layout = layoutFor(4)!;
const geometry = geometryOf(layout);
const cells = deal.givens;
console.log(layPairs(geometry,layout.slots.map(()=>true),pairsLeft(cells,"group"),seededRandom(42))?.order.length);4出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。