Reference · Rules, solvers and generation
randomFillingfunction
Grid lines that fill every cell, as lists of cells; null when this attempt painted itself into a corner.
Import it
import { randomFilling } from "@johnmorrisdotca/tsunagi";
Definition
function randomFilling(size: number, random: Random, longest: number, blocked?: ReadonlySet<number>, wrap?: boolean, hex?: boolean, style?: FillingStyle): number[][] | null
Parameters
| Name | Type | Description |
|---|---|---|
size | number | The number of cells on each side of the board. |
random | Random | A reproducible random source returning values in [0,1). |
longest | number | The maximum desired path length in cells. |
blocked (optional) | ReadonlySet<number> | Cells unavailable to generated paths. |
wrap (optional) | boolean | Whether opposite board edges connect. |
hex (optional) | boolean | Whether to use hexagonal neighbours. |
style (optional) | FillingStyle | Optional preferences for the seeded filling process. |
Returns
number[][] | null
Grid lines that fill every cell, as lists of cells; null when this attempt painted itself into a corner.
Examples
import { randomFilling, seededRandom } from "@johnmorrisdotca/tsunagi";
console.log(randomFilling(4,seededRandom(42),8));