Reference · Rules, solvers and generation
encodeLayoutfunction
A layout's code, from its cells, walls, waypoints and whether it wraps: the inverse of decodeLayout.
Import it
import { encodeLayout } from "@johnmorrisdotca/tsunagi";
Definition
function encodeLayout(cells: readonly number[], walls?: Iterable<string>, more?: { waypoints?: ReadonlyMap<number, number>; wrap?: boolean; hex?: boolean; sparse?: boolean; portals?: Iterable<readonly [number, number]>; strokes?: number | null; explosions?: LinkLayout["explosions"]; }): string
Parameters
| Name | Type | Description |
|---|---|---|
cells | readonly number[] | The row-major decoded cell values. |
walls (optional) | Iterable<string> | The blocked undirected edges as a-b strings. |
more (optional) | { waypoints?: ReadonlyMap<number, number>; wrap?: boolean; hex?: boolean; sparse?: boolean; portals?: Iterable<readonly [number, number]>; strokes?: number | null; explosions?: LinkLayout["explosions"]; } | Optional suffix rules and decorations for the encoded layout. |
Returns
string
A layout's code, from its cells, walls, waypoints and whether it wraps: the inverse of decodeLayout.
Examples
import { TSUNAGI_4 } from "@johnmorrisdotca/tsunagi/levels-4";
import { decodeLayout, encodeLayout } from "@johnmorrisdotca/tsunagi";
const givens = TSUNAGI_4[0][0];
const layout = decodeLayout(givens,4)!;
console.log(encodeLayout(layout.cells,layout.walls));A..AB..BC..CD..DWhat it prints (run when this page was built)