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

LinkLayouttype

A decoded board with pairs, cells, walls, waypoints, wrapping, portals and optional limits.

Import it

import type { LinkLayout } from "@johnmorrisdotca/tsunagi";

Definition

type LinkLayout = {
    size: number;
    cells: number[];
    ends: [
        number,
        number
    ][];
    walls: ReadonlySet<string>;
    waypoints: ReadonlyMap<number, number>;
    wrap: boolean;
    portalPairs: readonly (readonly [
        number,
        number
    ])[];
    portals: ReadonlyMap<number, number>;
    hex: boolean;
    sparse: boolean;
    strokes: number | null;
    explosions: {
        every: number;
        blast: boolean;
    } | null;
};

Members

NameTypeDescription
sizenumber
cellsnumber[]

One per cell: CELL_EMPTY (a waypoint too), CELL_BLOCKED, CELL_BRIDGE, or the pair a stone belongs to.

ends[number, number][]

Each pair's two stones, as cell indexes, the first met in reading order first.

wallsReadonlySet<string>

The edges no line may cross, each as edgeKey(a, b). Empty for a board with none.

waypointsReadonlyMap<number, number>

Empty cells only one pair's line may use, and must: the waypoint's cell to its pair.

wrapboolean

Whether the edges join: left to right and top to bottom.

portalPairsreadonly (readonly [number, number])[]

Each portal's two cells, the smaller first, the pairs in order of their smaller cell. Empty for a board with none.

portalsReadonlyMap<number, number>

Each portal cell's other cell. Empty for a board with none.

hexboolean

Whether the board is a hexagon of hexagons: six neighbours a cell, the square's corners off the board.

sparseboolean

Whether the board is sparse: few, long lines, at most sparseMost of them.

strokesnumber | null

How many strokes the player has to solve it in, or null for no limit.

explosions{ every: number; blast: boolean; } | null

Explosions: every every strokes a drawn line is broken — cut back by half, or, with blast, wiped with a neighbour cut too. Null for none.

Examples

import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { decodeLayout } from "@johnmorrisdotca/tsunagi";
import type { LinkLayout } from "@johnmorrisdotca/tsunagi";

const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
const value: LinkLayout = layout;
console.log(value);
{
  size: 4,
  cells: [
     0, -1, -1,  0,  1, -1,
    -1,  1,  2, -1, -1,  2,
     3, -1, -1,  3
  ],
  ends: [ [ 0, 3 ], [ 4, 7 ], [ 8, 11 ], [ 12, 15 ] ],
  walls: Set(0) {},
  waypoints: Map(0) {},
  wrap: false,
  portalPairs: [],
  portals: Map(0) {},
  hex: false,
  sparse: false,
  strokes: null,
  explosions: null
}

What it prints (run when this page was built)

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