Reference · Rules, solvers and generation
hexNeighboursOffunction
The six neighbours of a cell on the hexagon lattice, as indexes; fewer at an edge of the square (the hexagon's own edge is its # cells).
Import it
import { hexNeighboursOf } from "@johnmorrisdotca/tsunagi";
Definition
function hexNeighboursOf(size: number, at: number): number[]
Parameters
| Name | Type | Description |
|---|---|---|
size | number | The number of cells on each side of the board. |
at | number | The zero-based cell index. |
Returns
number[]
The six neighbours of a cell on the hexagon lattice, as indexes; fewer at an edge of the square (the hexagon's own edge is its # cells).
Examples
import { hexNeighboursOf } from "@johnmorrisdotca/tsunagi";
console.log(hexNeighboursOf(7,24));[ 17, 18, 25, 31, 30, 23 ]What it prints (run when this page was built)