twistBoardfunction
Turns one quadrant to finish the move. The whole board is read afterwards, because a turn can complete a line for either colour anywhere: one line wins for its owner, a line for each is a draw, and a full board with no line is a draw too.
Import it
import { twistBoard } from "@johnmorrisdotca/narabe";
Definition
function twistBoard(state: GameState, quadrant: number, clockwise: boolean): GameState
Parameters
| Name | Type | Description |
|---|---|---|
state | GameState | The current immutable game position. |
quadrant | number | The zero-based quadrant index. |
clockwise | boolean | Whether to turn clockwise rather than anticlockwise. |
Returns
GameState
The resulting position; a refused or inapplicable action leaves the input position unchanged.
Examples
import { createGame, playMove, twistBoard } from "@johnmorrisdotca/narabe";
console.log(twistBoard(playMove(createGame({variant:"twistFive"}),{row:0,col:0}),0,true).pendingTwist);falseWhat it prints (run when this page was built)