turnChoices関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { turnChoices } from "@johnmorrisdotca/narabe";
定義
function turnChoices(state: GameState): TurnChoices | null
引数
| 名前 | 型 | 説明 |
|---|---|---|
state | GameState | The current immutable game position. |
戻り値
TurnChoices | null
The native placement or movement choices, or null when no choice list applies.
例
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
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。