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

encodeLayoutfunction

A layout's code, from its cells, walls, waypoints and whether it wraps: the inverse of decodeLayout.

Import it

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

Definition

function encodeLayout(cells: readonly number[], walls?: Iterable<string>, more?: { waypoints?: ReadonlyMap<number, number>; wrap?: boolean; hex?: boolean; sparse?: boolean; portals?: Iterable<readonly [number, number]>; strokes?: number | null; explosions?: LinkLayout["explosions"]; }): string

Parameters

NameTypeDescription
cellsreadonly number[]

The row-major decoded cell values.

walls (optional)Iterable<string>

The blocked undirected edges as a-b strings.

more (optional){ waypoints?: ReadonlyMap<number, number>; wrap?: boolean; hex?: boolean; sparse?: boolean; portals?: Iterable<readonly [number, number]>; strokes?: number | null; explosions?: LinkLayout["explosions"]; }

Optional suffix rules and decorations for the encoded layout.

Returns

string

A layout's code, from its cells, walls, waypoints and whether it wraps: the inverse of decodeLayout.

Examples

import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { decodeLayout, encodeLayout } from "@johnmorrisdotca/tsunagi";

const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
console.log(encodeLayout(layout.cells,layout.walls));
A..AB..BC..CD..D

What it prints (run when this page was built)

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