goLegalfunction
Whether stone may play point: on the board, empty, not suicide, and
not the one point the simple ko rule forbids retaking this move —
exactly the point a single-stone capture just vacated, so the immediate
recapture cannot instantly restore the position it broke. Any other move
lifts the restriction; it is not the whole of positional superko, but it
is the actual rule most rule sets call "simple ko".
Import it
import { goLegal } from "@johnmorrisdotca/narabe/rules/go";
Definition
function goLegal(board: Cell[], size: number, point: Point, stone: Stone, koPoint: Point | null): boolean
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. |
point | Point | A zero-based row and column on the board. |
stone | Stone | The black or white colour being examined. |
koPoint | Point | null | The forbidden immediate-recapture point, or null without a ko restriction. |
Returns
boolean
Whether the point is on board, empty, not suicide and not the immediate ko point.
Examples
import { createGame, playMove } from "@johnmorrisdotca/narabe";
import { goLegal } from "@johnmorrisdotca/narabe/rules/go";
const point = {row:7,col:7};
const go = playMove(createGame({variant:"go",size:9}),{row:4,col:4});
console.log(goLegal(go.board, go.settings.size, point, "white", go.koPoint));trueWhat it prints (run when this page was built)