SearchGame
Defined in: src/modules/game-search/game.ts:11
The rules of a turn-based game as four functions over plain states, with no
world: all a search needs. S is the game state, M a move, P the
player id (default number).
A state is final when moves returns an empty list; a game with forced
passes models the pass as a move. Chance (dice, shuffles) lives in the
state, for example a SeededRng’s state field, so apply stays
deterministic.
Type Parameters
Section titled “Type Parameters”S
M
P = number
Properties
Section titled “Properties”apply: (
state,move) =>S
Defined in: src/modules/game-search/game.ts:16
A new state with move played; never mutates state, and returns the
same result for the same arguments.
Parameters
Section titled “Parameters”S
M
Returns
Section titled “Returns”S
currentPlayer
Section titled “currentPlayer”currentPlayer: (
state) =>P
Defined in: src/modules/game-search/game.ts:18
Who moves in state, compared with ===. Only called on non-final states.
Parameters
Section titled “Parameters”S
Returns
Section titled “Returns”P
moves: (
state) => readonlyM[]
Defined in: src/modules/game-search/game.ts:24
The legal moves in state, or [] once the game is over. Returns the
same order for the same state; searches try moves in that order, so list
likely-good moves first.
Parameters
Section titled “Parameters”S
Returns
Section titled “Returns”readonly M[]
outcome
Section titled “outcome”outcome: (
state,player) =>number
Defined in: src/modules/game-search/game.ts:26
The result of a final state for player: -1 a loss, 0 a draw, 1 a win.
Parameters
Section titled “Parameters”S
player
Section titled “player”P
Returns
Section titled “Returns”number