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

TsunagiGametype

The complete immutable puzzle state, current stroke, undo history and assistance flags.

Import it

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

Definition

type TsunagiGame = {
    layout: LinkLayout;
    givens: string;
    answer: string | null;
    lines: Lines;
    undo: readonly Lines[];
    strokes: number;
    drawing: number | null;
    before: Lines | null;
    reach: Reach;
    flagged: readonly number[] | null;
    blasted: readonly number[] | null;
    exploded: "boom" | "blast" | null;
    checked: {
        unjoined: number;
        empty: number;
    } | null;
    cheats: boolean;
    explosions: TsunagiExplosionChoice;
    eased: TsunagiHelp | null;
    cheated: boolean;
    solved: boolean;
};

Members

NameTypeDescription
layoutLinkLayout

The layout as it is played: its explosions as chosen.

givensstring

The layout code the game was made from, which decides which line an explosion breaks.

answerstring | null
linesLines
undoreadonly Lines[]

What Undo would give back, most recent last: up to 200.

strokesnumber

Strokes taken since the game started or was restarted.

drawingnumber | null

The pair being drawn this moment, or null between strokes.

beforeLines | null

The lines as they were when the pair being drawn was pressed.

reachReach

How far the finger is from the end of the line it draws, once that has been through a portal (Reach).

flaggedreadonly number[] | null

Pairs Check found not joined, until the board next changes.

blastedreadonly number[] | null

The cells the last explosion took a line out of, until the next press.

exploded"boom" | "blast" | null

What the last explosion did: boom (one line halved) or blast (a line wiped and its neighbour halved).

checked{ unjoined: number; empty: number; } | null

What Check said last, until the board changes: how many pairs are not joined, and how many cells are empty.

cheatsboolean
explosionsTsunagiExplosionChoice
easedTsunagiHelp | null

The help the explosions' choice amounts to on this board: softened or off, where the board has any; null otherwise.

cheatedboolean

Whether Cheat was used in this attempt.

solvedboolean

Examples

import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { newTsunagiGame } from "@johnmorrisdotca/tsunagi";
import type { TsunagiGame } from "@johnmorrisdotca/tsunagi";

const givens = TSUNAGI_4[0][0];
const answer = TSUNAGI_4[0][1];
const game = newTsunagiGame(givens,4,{answer,cheats:true})!;
const value: TsunagiGame = game;
console.log(value);
{
  layout: {
    size: 4,
    cells: [
       0, -1, -1,  0,  1, -1,
      -1,  1,  2, -1, -1,  2,
       3, -1, -1,  3
    ],
    ends: [ [Array], [Array], [Array], [Array] ],
    walls: Set(0) {},
    waypoints: Map(0) {},
    wrap: false,
    portalPairs: [],
    portals: Map(0) {},
    hex: false,
    sparse: false,
    strokes: null,
    explosions: null
  },
  givens: 'A..AB..BC..CD..D',
  answer: 'AAAABBBBCCCCDDDD',
  lines: [ [], [], [], [] ],
  undo: [],
  strokes: 0,
  drawing: null,
  before: null,
  reach: { dr: 0, dc: 0 },
  flagged: null,
  blasted: null,
  exploded: null,
  checked: null,
  cheats: true,
  explosions: 'on',
  eased: null,
  cheated: false,
  solved: false
}

What it prints (run when this page was built)

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