withBridges関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Lines that fill a board with want bridges made in them: where a line runs straight through a cell away from the edge
and two other lines each end on the cells either side of it the other way, those two are joined into one line over
the cell, which becomes a bridge. Null where they offer no place for them.
インポート
import { withBridges } from "@johnmorrisdotca/tsunagi";
定義
function withBridges(size: number, lines: readonly number[][], random: Random, want: number): { paths: number[][]; bridges: Set<number>; } | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
size | number | The number of cells on each side of the board. |
lines | readonly number[][] | The lines that fill the board. |
random | Random | A reproducible random source returning values in [0,1). |
want | number | The requested number of bridges. |
戻り値
{ paths: number[][]; bridges: Set<number>; } | null
The lines and the bridges, or null.
例
import { randomFilling, seededRandom, withBridges } from "@johnmorrisdotca/tsunagi";
const random = seededRandom(42);
const lines = randomFilling(6,random,12);
console.log(lines === null ? null : withBridges(6,lines,random,1));この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。