applyActionfunction
Plays one move: a piece is laid, every full row and column clears together, and the tray fills when it is empty. A move that cannot be made is refused and changes nothing.
Import it
import { applyAction } from "@johnmorrisdotca/houseki/tsumiki";
Definition
function applyAction(state: GameState, action: Action): ActionResult
Parameters
| Name | Type | Description |
|---|---|---|
state | GameState | The game. |
action | Action | The placement. |
Returns
ActionResult
Whether it was taken, the state after it, and what happened; a refused move returns the same state.
Examples
import { applyAction, createGame, legalActions } from "@johnmorrisdotca/houseki/tsumiki";
const game = createGame({ seed: "demo" });
console.log(applyAction(game, legalActions(game)[0]!).state.moves);1What it prints (run when this page was built)