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

Linestype

THE LINES A PLAYER HAS DRAWN, and what a press and a drag do to them.

Pure, and the only place the drawing rules live: the grid reports where a finger went, and this says what the lines are now. Each pair has one line, an ordered list of cells starting at one of its stones; an empty list is no line. Every function returns new lines and leaves the ones it was given alone, the way the engine does.

  • Press on a stone: a fresh line starts there, and the pair's old one goes. A press let go without moving is a tap, and clears the line.
  • Press on a line: it is cut back to that cell, and drawing goes on from it.
  • Drag into the next cell: the line grows. Back over itself: it shortens, cell by cell, as the finger goes. Into another pair's line: that line is cut back to before the cell, and this one goes through. Into another pair's stone, a blocked cell, across a wall, or past its own far stone: nothing.
  • Into a portal: the line goes in at one cell and comes out of the other, going on the same way, into the cell beyond it, in the one drag; the line's list has both portal cells between the cell before and the cell after, and no line ever ends on a portal. Backing over a portal takes the line back to before it. Another line already holding a portal's cells is cut back to before them, as for any cell. See dragFinger for what a finger over the board draws toward once a line has been through one.
  • Onto a bridge: only to go straight on (steps.ts); another line already going the same way over it is cut back, and a line never crosses itself. A bridge is in a line's list between the cells either side of it, and a line let go with its tip on a bridge ends before it. Pressing on a bridge draws nothing: two lines may be there.

Import it

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

Definition

type Lines = readonly (readonly number[])[];

Members

NameTypeDescription
lengthnumber

Gets the length of the array. This is a number one higher than the highest element defined in an array.

toString(): string

Returns a string representation of an array.

toLocaleString(): string (locales: string | string[], options?: Intl.NumberFormatOptions & Intl.DateTimeFormatOptions): string

Returns a string representation of an array. The elements are converted to string using their toLocaleString methods.

concat(...items: ConcatArray<readonly number[]>[]): (readonly number[])[] (...items: (readonly number[] | ConcatArray<readonly number[]>)[]): (readonly number[])[]

Combines two or more arrays.

join(separator?: string): string

Adds all the elements of an array separated by the specified separator string.

slice(start?: number, end?: number): (readonly number[])[]

Returns a section of an array.

indexOf(searchElement: readonly number[], fromIndex?: number): number

Returns the index of the first occurrence of a value in an array.

lastIndexOf(searchElement: readonly number[], fromIndex?: number): number

Returns the index of the last occurrence of a specified value in an array.

every<S extends readonly number[]>(predicate: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => value is S, thisArg?: any): this is readonly S[] (predicate: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => unknown, thisArg?: any): boolean

Determines whether all the members of an array satisfy the specified test.

some(predicate: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => unknown, thisArg?: any): boolean

Determines whether the specified callback function returns true for any element of an array.

forEach(callbackfn: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => void, thisArg?: any): void

Performs the specified action for each element in an array.

map<U>(callbackfn: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => U, thisArg?: any): U[]

Calls a defined callback function on each element of an array, and returns an array that contains the results.

filter<S extends readonly number[]>(predicate: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => value is S, thisArg?: any): S[] (predicate: (value: readonly number[], index: number, array: readonly (readonly number[])[]) => unknown, thisArg?: any): (readonly number[])[]

Returns the elements of an array that meet the condition specified in a callback function.

reduce(callbackfn: (previousValue: readonly number[], currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => readonly number[]): readonly number[] (callbackfn: (previousValue: readonly number[], currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => readonly number[], initialValue: readonly number[]): readonly number[] <U>(callbackfn: (previousValue: U, currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

reduceRight(callbackfn: (previousValue: readonly number[], currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => readonly number[]): readonly number[] (callbackfn: (previousValue: readonly number[], currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => readonly number[], initialValue: readonly number[]): readonly number[] <U>(callbackfn: (previousValue: U, currentValue: readonly number[], currentIndex: number, array: readonly (readonly number[])[]) => U, initialValue: U): U

Calls the specified callback function for all the elements in an array, in descending order. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.

find<S extends readonly number[]>(predicate: (value: readonly number[], index: number, obj: readonly (readonly number[])[]) => value is S, thisArg?: any): S | undefined (predicate: (value: readonly number[], index: number, obj: readonly (readonly number[])[]) => unknown, thisArg?: any): readonly number[] | undefined

Returns the value of the first element in the array where predicate is true, and undefined otherwise.

findIndex(predicate: (value: readonly number[], index: number, obj: readonly (readonly number[])[]) => unknown, thisArg?: any): number

Returns the index of the first element in the array where predicate is true, and -1 otherwise.

entries(): ArrayIterator<[number, readonly number[]]>

Returns an iterable of key, value pairs for every entry in the array

keys(): ArrayIterator<number>

Returns an iterable of keys in the array

values(): ArrayIterator<readonly number[]>

Returns an iterable of values in the array

includes(searchElement: readonly number[], fromIndex?: number): boolean

Determines whether an array includes a certain element, returning true or false as appropriate.

flatMap<U, This = undefined>(callback: (this: This, value: readonly number[], index: number, array: (readonly number[])[]) => U | readonly U[], thisArg?: This | undefined): U[]

Calls a defined callback function on each element of an array. Then, flattens the result into a new array. This is identical to a map followed by flat with depth 1.

flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[]

Returns a new array with all sub-array elements concatenated into it recursively up to the specified depth.

at(index: number): readonly number[] | undefined

Returns the item located at the specified index.

Examples

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

const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
const lines = noLines(layout);
const value: Lines = lines;
console.log(value);
[ [], [], [], [] ]

What it prints (run when this page was built)

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