Reference · Rules, solvers and generation
TsunagiBoardtype
THE BOARD A GENERATOR WORKS ON, as a graph: which cells a line may stand on, and
which cells each is beside. A square, an oblong, a honeycomb, a board whose edges
join and a board of any outline are all this one thing, so one generator
(generator.ts) makes all of them.
Every board is still written as a square of cells (code.ts), and one that is not
the whole of its square says shape, so a level is read, solved and checked by what
has always read, solved and checked levels.
Imports carry their .ts so a level script can run this under plain node.
Import it
import type { TsunagiBoard } from "@johnmorrisdotca/tsunagi";
Definition
type TsunagiBoard = {
size: number;
hex: boolean;
wrap: boolean;
shape: boolean;
closed: ReadonlySet<number>;
blocked: ReadonlySet<number>;
cells: readonly number[];
around: readonly (readonly number[])[];
};
Members
| Name | Type | Description |
|---|---|---|
size | number | The side of the square it is written in. |
hex | boolean | |
wrap | boolean | |
shape | boolean | Whether it says |
closed | ReadonlySet<number> | The cells of the square no line may stand on: off the board, and blocked. |
blocked | ReadonlySet<number> | Those inside the board, which are drawn as blocked. |
cells | readonly number[] | The cells a line may stand on, in reading order. |
around | readonly (readonly number[])[] | What is beside each cell of the square: only cells a line may stand on. |
Examples
import { squareBoard } from "@johnmorrisdotca/tsunagi";
import type { TsunagiBoard } from "@johnmorrisdotca/tsunagi";
const value: TsunagiBoard = squareBoard(5);
console.log(value.cells.length);25What it prints (run when this page was built)