Reference · Rules, solvers and generation
offBoardCellsfunction
The cells of a square that are off the board on a board with a shape: every # that reaches the square's edge
through other # cells, by a square's four steps or a honeycomb's six.
Import it
import { offBoardCells } from "@johnmorrisdotca/tsunagi";
Definition
function offBoardCells(grid: string, size: number, hex: boolean): Set<number>
Parameters
| Name | Type | Description |
|---|---|---|
grid | string | The cells of the layout, one character each. |
size | number | The number of cells on each side of the board. |
hex | boolean | Whether to use hexagonal neighbours. |
Returns
Set<number>
The cells of the square that are off the board.
Examples
import { offBoardCells } from "@johnmorrisdotca/tsunagi";
console.log([...offBoardCells("A.#A.#####",3,false)]);[ 8, 2, 7, 5, 6 ]What it prints (run when this page was built)