groupAtfunction
The connected group of stones sharing the colour at from, and the empty
points touching any of them — its liberties. A group with none is what
capturing takes off the board.
Import it
import { groupAt } from "@johnmorrisdotca/narabe/rules/go";
Also exported from: @johnmorrisdotca/narabe
Definition
function groupAt(board: Cell[], size: number, from: Point): { stones: Point[]; liberties: Set<number>; }
Parameters
| Name | Type | Description |
|---|---|---|
board | Cell[] | The row-major board cells; null marks an empty point. |
size | number | The number of cells on each side of the board. |
from | Point | The source point of the group or moving piece. |
Returns
{ stones: Point[]; liberties: Set<number>; }
The connected same-colour stones and their empty neighbouring indices.
Examples
import { createGame, playMove } from "@johnmorrisdotca/narabe";
import { groupAt } from "@johnmorrisdotca/narabe/rules/go";
const go = playMove(createGame({variant:"go",size:9}),{row:4,col:4});
console.log(groupAt(go.board, go.settings.size, {row:4,col:4}).liberties.size);4What it prints (run when this page was built)