playMovefunction
Plays the stone to move at point. Illegal moves (occupied intersection,
obstacle, off the board, forbidden shape, outside the opening, or game
already over) return the state unchanged.
Import it
import { playMove } from "@johnmorrisdotca/narabe";
Definition
function playMove(state: GameState, where: Point, kind?: Move["kind"], chosen?: Stone | null): GameState
Parameters
| Name | Type | Description |
|---|---|---|
state | GameState | The current immutable game position. |
where | Point | The requested point, resolved by the placement rule. |
kind (optional) | MoveKind | The recorded move kind. |
chosen (optional) | Stone | null | The chosen colour where the variant allows one; null uses the mover. |
Returns
GameState
The resulting position; a refused or inapplicable action leaves the input position unchanged.
Examples
import { createGame, playMove } from "@johnmorrisdotca/narabe";
const state = createGame({variant:"freestyle",size:15});
const point = {row:7,col:7};
console.log(playMove(state, point).moves.length);1What it prints (run when this page was built)