GameState型
リファレンスの説明と例は英語です。見出しと目次は日本語です。
The complete immutable position and its move history, seats and outcome.
インポート
import type { GameState } from "@johnmorrisdotca/narabe";
定義
type GameState = {
settings: GameSettings;
board: Cell[];
moves: Move[];
opener: Stone;
seats: Record<Stone, Seat>;
swapsUsed: Record<Seat, number>;
captures: Record<Stone, number>;
opening: OpeningState;
toPlay: Stone;
pendingTwist: boolean;
kings: readonly Point[];
chainAt: Point | null;
koPoint: Point | null;
status: GameStatus;
winner: Stone | null;
winBy: WinReason | null;
winningLine: Point[];
};
メンバー
| 名前 | 型 | 説明 |
|---|---|---|
settings | GameSettings | |
board | Cell[] | |
moves | Move[] | Every move played so far, in order. |
opener | Stone | The colour that opened, kept so the game can be replayed from move zero. |
seats | Record<Stone, Seat> | Which seat currently holds each colour. Exchanged by |
swapsUsed | Record<Seat, number> | Swaps each seat has spent, counted against |
captures | Record<Stone, number> | Pairs each colour has captured. Always zero outside the capture variants. |
opening | OpeningState | |
toPlay | Stone | |
pendingTwist | boolean | True between placing a stone and turning a quadrant, in the twist games. |
kings | readonly Point[] | Board squares holding a crowned piece, in the checkers family. Empty everywhere else. |
chainAt | Point | null | The square of a piece mid-capture-chain that must keep jumping, in the checkers family. Null otherwise. |
koPoint | Point | null | The point the simple ko rule forbids retaking this move, in Go. Null otherwise. |
status | GameStatus | |
winner | Stone | null | |
winBy | WinReason | null | |
winningLine | Point[] | The stones that completed the winning line, empty until someone wins. |
例
import { createGame, playMove } from "@johnmorrisdotca/narabe";
import type { GameState } from "@johnmorrisdotca/narabe";
const state = createGame({variant:"freestyle",size:15});
const point = {row:7,col:7};
const value: GameState = playMove(state,point);
console.log(value);{
settings: {
size: 15,
winLength: 5,
variant: 'freestyle',
opening: 'free',
handicap: {
stone: null,
doubleThree: false,
doubleFour: false,
overline: false,
exactLine: false,
openLine: false,
longerLine: false,
singleStone: false,
noCaptures: false,
secondStoneExclusion: 0
},
headStart: { stone: null, freeTurns: 0, traditional: 0 },
seed: 0,
capturesToWin: 10,
firstPlayer: 'black',
obstacles: 'none',
allowUndo: true,
allowSkip: false,
allowSwap: false,
allowResize: false,
swapsPerSeat: 1,
drawLimit: 'none'
},
board: [
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null, null, null, null, null,
... 125 more items
],
moves: [ { row: 7, col: 7, stone: 'black', kind: 'place' } ],
opener: 'black',
seats: { black: 'one', white: 'two' },
swapsUsed: { one: 0, two: 0 },
captures: { black: 0, white: 0 },
opening: { stage: 'done', actor: null, choices: [] },
toPlay: 'white',
pendingTwist: false,
kings: [],
chainAt: null,
koPoint: null,
status: 'playing',
winner: null,
winBy: null,
winningLine: []
}出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。