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

withBridgesfunction

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 it

import { withBridges } from "@johnmorrisdotca/tsunagi";

Definition

function withBridges(size: number, lines: readonly number[][], random: Random, want: number): { paths: number[][]; bridges: Set<number>; } | null

Parameters

NameTypeDescription
sizenumber

The number of cells on each side of the board.

linesreadonly number[][]

The lines that fill the board.

randomRandom

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

wantnumber

The requested number of bridges.

Returns

{ paths: number[][]; bridges: Set<number>; } | null

The lines and the bridges, or null.

Examples

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

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