turnChoicesfunction
What the colour to move may do this turn — every piece that has a move, or every point that may be played — and whether a rule narrowed it.
A question put to the engine's own answers, adding no rule of its own:
pieceMoves and legalPoints already decide what is legal, and this gathers
them so a board can show a player the few things they may do without working
any of it out itself. The board's marking reads this and nothing else.
The dependency runs one way, from here into the engine, as record.ts does;
nothing in the engine calls this.
Null where a turn has no set of moves to show: a finished game, a quarter turn owed, a game whose piece is laid by its footprint from a queue, and Go, where a pass is always on offer beside the points.
Import it
import { turnChoices } from "@johnmorrisdotca/narabe";
Definition
function turnChoices(state: GameState): TurnChoices | null
Parameters
| Name | Type | Description |
|---|---|---|
state | GameState | The current immutable game position. |
Returns
TurnChoices | null
The native placement or movement choices, or null when no choice list applies.
Examples
import { createGame, turnChoices } from "@johnmorrisdotca/narabe";
const state = createGame({variant:"freestyle",size:15});
console.log(turnChoices(state));{
kind: 'place',
points: [
{ row: 0, col: 0 }, { row: 0, col: 1 }, { row: 0, col: 2 },
{ row: 0, col: 3 }, { row: 0, col: 4 }, { row: 0, col: 5 },
{ row: 0, col: 6 }, { row: 0, col: 7 }, { row: 0, col: 8 },
{ row: 0, col: 9 }, { row: 0, col: 10 }, { row: 0, col: 11 },
{ row: 0, col: 12 }, { row: 0, col: 13 }, { row: 0, col: 14 },
{ row: 1, col: 0 }, { row: 1, col: 1 }, { row: 1, col: 2 },
{ row: 1, col: 3 }, { row: 1, col: 4 }, { row: 1, col: 5 },
{ row: 1, col: 6 }, { row: 1, col: 7 }, { row: 1, col: 8 },
{ row: 1, col: 9 }, { row: 1, col: 10 }, { row: 1, col: 11 },
{ row: 1, col: 12 }, { row: 1, col: 13 }, { row: 1, col: 14 },
{ row: 2, col: 0 }, { row: 2, col: 1 }, { row: 2, col: 2 },
{ row: 2, col: 3 }, { row: 2, col: 4 }, { row: 2, col: 5 },
{ row: 2, col: 6 }, { row: 2, col: 7 }, { row: 2, col: 8 },
{ row: 2, col: 9 }, { row: 2, col: 10 }, { row: 2, col: 11 },
{ row: 2, col: 12 }, { row: 2, col: 13 }, { row: 2, col: 14 },
{ row: 3, col: 0 }, { row: 3, col: 1 }, { row: 3, col: 2 },
{ row: 3, col: 3 }, { row: 3, col: 4 }, { row: 3, col: 5 },
{ row: 3, col: 6 }, { row: 3, col: 7 }, { row: 3, col: 8 },
{ row: 3, col: 9 }, { row: 3, col: 10 }, { row: 3, col: 11 },
{ row: 3, col: 12 }, { row: 3, col: 13 }, { row: 3, col: 14 },
{ row: 4, col: 0 }, { row: 4, col: 1 }, { row: 4, col: 2 },
{ row: 4, col: 3 }, { row: 4, col: 4 }, { row: 4, col: 5 },
{ row: 4, col: 6 }, { row: 4, col: 7 }, { row: 4, col: 8 },
{ row: 4, col: 9 }, { row: 4, col: 10 }, { row: 4, col: 11 },
{ row: 4, col: 12 }, { row: 4, col: 13 }, { row: 4, col: 14 },
{ row: 5, col: 0 }, { row: 5, col: 1 }, { row: 5, col: 2 },
{ row: 5, col: 3 }, { row: 5, col: 4 }, { row: 5, col: 5 },
{ row: 5, col: 6 }, { row: 5, col: 7 }, { row: 5, col: 8 },
{ row: 5, col: 9 }, { row: 5, col: 10 }, { row: 5, col: 11 },
{ row: 5, col: 12 }, { row: 5, col: 13 }, { row: 5, col: 14 },
{ row: 6, col: 0 }, { row: 6, col: 1 }, { row: 6, col: 2 },
{ row: 6, col: 3 }, { row: 6, col: 4 }, { row: 6, col: 5 },
{ row: 6, col: 6 }, { row: 6, col: 7 }, { row: 6, col: 8 },
{ row: 6, col: 9 },
... 125 more items
],
count: 225
}What it prints (run when this page was built)