Reference · Rules, generation and deductions
neighboursOffunction
Precomputes the neighbour list for each row-major cell.
Import it
import { neighboursOf } from "@johnmorrisdotca/jirai";
Definition
function neighboursOf(settings: Settings): number[][]
Parameters
| Name | Type | Description |
|---|---|---|
settings | Settings | The validated native field dimensions, mine count, topology, shape, opening, generation policy and numeric seed. |
Returns
number[][]
Precomputes the neighbour list for each row-major cell.
Examples
import type { Settings } from "@johnmorrisdotca/jirai";
import { neighboursOf } from "@johnmorrisdotca/jirai";
const settings: Settings={width:3,height:3,mines:1,grid:"square",noGuess:false,opening:"clear",seed:42};
console.log(neighboursOf(settings));[
[ 1, 3, 4 ],
[ 0, 2, 3, 4, 5 ],
[ 1, 4, 5 ],
[ 0, 1, 4, 6, 7 ],
[
0, 1, 2, 3,
5, 6, 7, 8
],
[ 1, 2, 4, 7, 8 ],
[ 3, 4, 7 ],
[ 3, 4, 5, 6, 8 ],
[ 4, 5, 7 ]
]What it prints (run when this page was built)