placePiecefunction
Lays the piece in hand on cells. The cells must be that piece in some
orientation, on empty points. A piece carries both colours, so it can
finish a line for either side: one line wins for its owner, whoever laid
it; a line for each is a draw.
Import it
import { placePiece } from "@johnmorrisdotca/narabe";
Definition
function placePiece(state: GameState, cells: readonly PieceCell[]): GameState
Parameters
| Name | Type | Description |
|---|---|---|
state | GameState | The current immutable game position. |
cells | readonly PieceCell[] | The absolute coloured cells of the piece placement. |
Returns
GameState
The resulting position; a refused or inapplicable action leaves the input position unchanged.
Examples
import { createGame, piecePlacements, placePiece } from "@johnmorrisdotca/narabe";
const queued = createGame({variant:"dominoFive",seed:42});
console.log(placePiece(queued, piecePlacements(queued)[0]).moves.length);1What it prints (run when this page was built)