scoreAreafunction
The area score: every stone on the board, plus every empty region whose only neighbours are one colour. An empty region touching both colours, or touching neither (an empty board), counts for nobody — dame, not territory. Dead stones are not marked or removed here: a stone left on the board still counts as a stone, so a player who wants credit for territory a stray stone sits in has to capture it before passing, the same as playing it out at the real table.
Import it
import { scoreArea } from "@johnmorrisdotca/narabe/rules/go";
Also exported from: @johnmorrisdotca/narabe
Definition
function scoreArea(board: Cell[], size: number): { black: number; white: 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. |
Returns
{ black: number; white: number; }
The raw black and white area totals, without komi.
Examples
import { createGame, playMove } from "@johnmorrisdotca/narabe";
import { scoreArea } from "@johnmorrisdotca/narabe/rules/go";
const go = playMove(createGame({variant:"go",size:9}),{row:4,col:4});
console.log(scoreArea(go.board, go.settings.size));{ black: 81, white: 0 }What it prints (run when this page was built)