Skip to the content

Houseki宝石

Run five native gem and stone engines, play measured challenges and lessons, and save deterministic games.

Houseki (宝石) is Japanese for a gem or precious stone. About the name

Contents

Reference · Tsumiki

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

NameTypeDescription
stateGameState

The game.

actionAction

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);
1

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/houseki 0.5.0.