Reference · Pipes, rules and solving
neighboursOffunction
Which cell is next to each cell on each side: table[cell * 4 + side], or -1
where there is no cell (the edge of a board that does not wrap) or a wall.
Import it
import { neighboursOf } from "@johnmorrisdotca/suido";
Definition
function neighboursOf(layout: Pick<Layout, "width" | "height" | "wrap"> & { walls?: readonly number[]; }): Int32Array
Parameters
| Name | Type | Description |
|---|---|---|
layout | Pick<Layout, "wrap" | "width" | "height"> & { walls?: readonly number[]; } | The decoded board with its dimensions, pipe masks and rule settings. |
Returns
Int32Array<ArrayBufferLike>
Which cell is next to each cell on each side: table[cell * 4 + side], or -1 where there is no cell (the edge of a board that does not wrap) or a wall.
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, neighboursOf } from "@johnmorrisdotca/suido";
const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
console.log(neighboursOf(layout).slice(0,8));Int32Array(8) [
-1, 1, 5, -1,
-1, 2, 6, 0
]What it prints (run when this page was built)