Skip to the content

Tsunagi繋ぎ

Join each pair with a separate line and fill the board, through fixed levels or seeded puzzles.

Tsunagi means joining in Japanese. About the name

Contents

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

NameTypeDescription
sizenumber

The number of cells on each side of the board.

randomRandom

A reproducible random source returning values in [0,1).

longestnumber

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));

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tsunagi 1.7.0.