import type { Cell, GameState, MoverRules, Point, Stone } from "../types.ts"; /** * The mechanics that some games add to placing a stone: where a dropped * stone lands, what a stone decides on arrival beyond a line, the quarter * turn that finishes a move in the twist games, and the slides of the games * with a handful of pieces. Each is consulted by `engine.ts` through the * variant's spec. */ /** What a mill game's man coming to rest decides: the taking of a man if it made a mill, and otherwise the end of the turn. */ export declare function settleMillTurn(state: GameState, to: Point): GameState; /** The other colour's turn, unless it cannot take one: down to two men with all laid, or with no move, it has lost. */ export declare function millTurnOver(state: GameState): GameState; /** Lays a man, or takes one where a mill is owed its taking: the two things `playMove` means in a mill game. */ export declare function playMillPoint(state: GameState, point: Point): GameState; /** What a moving game's man coming to rest decides. */ export declare function settleMover(before: GameState, moved: GameState, to: Point, rules: MoverRules): GameState; /** An Amazons arrow lands: the square is gone for good, and the turn passes, or the game ends if the other side can no longer move. */ export declare function shootArrow(state: GameState, point: Point): GameState; /** A finished game. */ export declare function won(state: GameState, winner: Stone, winBy: GameState["winBy"], winningLine: Point[]): GameState; /** * The game is over because there is no play left in it — the board filled, or * neither side has a move. Both are the same event, so both end the same way, * and the two of them are stated here once rather than in each caller. * * Who an exhausted board favours is the variant's business: the giveaway * games hand it to whoever opened, since surviving to the end without making * a line is what winning is there, and the breaker game hands it to the * breaker for the same reason. Every other game calls it a draw, because * neither player did the thing the game asks for. * * `why` is the caller's, because a full board and a blocked one are not the * same sentence to read afterwards even when they settle alike. */ export declare function noPlayLeft(state: GameState, why: GameState["winBy"]): GameState; /** * Where a stone played at `point` actually goes: the same point, or in a * drop game the bottom of its column. A click anywhere in a column is a play * in that column. * * @param state - The current immutable game position. * @param point - A zero-based row and column on the board. * @returns Where a stone played at `point` actually goes: the same point, or in a drop game the bottom of its column. A click anywhere in a column is a play in that column. * @example * ```ts * import { createGame, resolvePlacement } from "@johnmorrisdotca/narabe"; * * const drop = createGame({variant:"dropFour"}); * console.log(resolvePlacement(drop,{row:0,col:0})); * ``` */ export declare function resolvePlacement(state: GameState, point: Point): Point; /** * Four-edge gravity: a stone must rest against the edge of the board or, * orthogonally, against something already there. Nothing floats. */ export declare function restsOnSomething(state: GameState, point: Point): boolean; /** * The giveaway rule that stops a player being forced into a four: you may * not play directly on top of the opponent's last stone while any other * column has room. */ export declare function blockedByGiveaway(state: GameState, point: Point): boolean; /** Whether the colour to move has all its pieces down and must now slide one. * * @param state - The current immutable game position. * @returns Whether the colour to move has all its pieces down and must now slide one. * @example * ```ts * import { createGame, inMovePhase } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(inMovePhase(state)); * ``` */ export declare function inMovePhase(state: GameState): boolean; /** * What a stone arriving at `point` decides, if anything: a line, a square, a * fifth captured pair, or — in the trap game — a losing line. Null when the * game goes on. A win outranks a trap: four in a row is not also three. */ export declare function settleStone(state: GameState, point: Point, mover?: Stone): GameState | null; /** Whether the colour to move owes a quarter turn before the move is complete. * * @param state - The current immutable game position. * @returns Whether the colour to move owes a quarter turn before the move is complete. * @example * ```ts * import { canTwist, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(canTwist(state)); * ``` */ export declare function canTwist(state: GameState): boolean; /** * Turns one quadrant to finish the move. The whole board is read afterwards, * because a turn can complete a line for either colour anywhere: one line * wins for its owner, a line for each is a draw, and a full board with no line * is a draw too. * * @param state - The current immutable game position. * @param quadrant - The zero-based quadrant index. * @param clockwise - Whether to turn clockwise rather than anticlockwise. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { createGame, playMove, twistBoard } from "@johnmorrisdotca/narabe"; * * console.log(twistBoard(playMove(createGame({variant:"twistFive"}),{row:0,col:0}),0,true).pendingTwist); * ``` */ export declare function twistBoard(state: GameState, quadrant: number, clockwise: boolean): GameState; /** Where a piece of the colour to move may step from `from`; empty if it may not move. * * @param state - The current immutable game position. * @param from - The source point of the group or moving piece. * @returns Where a piece of the colour to move may step from `from`; empty if it may not move. * @example * ```ts * import { createGame, pieceMoves } from "@johnmorrisdotca/narabe"; * * const checkers = createGame({variant:"checkers"}); * console.log(pieceMoves(checkers,{row:5,col:0})); * ``` */ export declare function pieceMoves(state: GameState, from: Point): Point[]; /** Slides a piece one step, or in checkers a step or a capture. Illegal moves return the state unchanged. * * @param state - The current immutable game position. * @param from - The source point of the group or moving piece. * @param to - The destination point of the moving piece. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { createGame, movePiece } from "@johnmorrisdotca/narabe"; * * const checkers = createGame({variant:"checkers"}); * console.log(movePiece(checkers,{row:5,col:0},{row:4,col:1}).moves.length); * ``` */ export declare function movePiece(state: GameState, from: Point, to: Point): GameState; /** * The falling-block rule: a full bottom row vanishes and everything above it * drops a row. Returns the board and the row that went, or null when the * bottom row still has a gap. Only stones fill a row; a dead square never * does, so the two rules are not combined in any variant. */ export declare function clearBottomRow(board: Cell[], size: number): { board: Cell[]; cleared: Cell[]; } | null; /** Puts a cleared row back: the inverse of `clearBottomRow`. */ export declare function restoreBottomRow(board: Cell[], size: number, cleared: Cell[]): Cell[];