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
| Name | Type | Description |
|---|---|---|
size | number | |
cells | number[] | One per cell: |
ends | [number, number][] | Each pair's two stones, as cell indexes, the first met in reading order first. |
walls | ReadonlySet<string> | The edges no line may cross, each as |
waypoints | ReadonlyMap<number, number> | Empty cells only one pair's line may use, and must: the waypoint's cell to its pair. |
wrap | boolean | Whether the edges join: left to right and top to bottom. |
portalPairs | readonly (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. |
portals | ReadonlyMap<number, number> | Each portal cell's other cell. Empty for a board with none. |
hex | boolean | Whether the board is a hexagon of hexagons: six neighbours a cell, the square's corners off the board. |
sparse | boolean | Whether the board is sparse: few, long lines, at most |
strokes | number | null | How many strokes the player has to solve it in, or null for no limit. |
explosions | { every: number; blast: boolean; } | null | Explosions: every |
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)