import type { GameSettings, GameState, OpeningChoice, OpeningState, Point, Seat, Stone } from "../types.ts"; /** * Opening protocols. Two kinds live here: placement restrictions (pro, long * pro, the RIF opening) that only narrow where the first stones may go, and * swap protocols where one seat lays every stone for a while and the other * then picks a colour. The engine asks `openingAllows` before every stone and * `openingAfterMove` after, and never looks at the protocol by name. */ /** * Half-widths of the central squares the openings refer to. The first two are * exported for the set-up screen's picture of each opening, which draws the * square from these rather than from a second copy of the numbers. */ export declare const PRO_EXCLUSION = 2; export declare const LONG_PRO_EXCLUSION = 3; /** * WHETHER THE OPENING IS WHAT DECIDES WHO PLAYS WHICH COLOUR. * * Asked by the doorstep, which states every fact a game will be played under * before it is created — and the colours are the fact people most want. Under * these five protocols the seats are settled and the colours are not: one * player lays the first stones and the other looks at the position and chooses, * so any claim made beforehand about who is black would be a guess. * * Here rather than in the page, because it is a rule of the game and rules live * with the engine. The page asks; it does not keep its own list. A sixth * swapping protocol added to either list above is then answered correctly by * everything that asks, which a list copied into a component would not be. * * "I do not know yet" is the honest answer this enables, and the alternative is * the dangerous kind of plausible: naming black would be in range, readable, * and wrong half the time. */ export declare function openingDecidesColours(opening: GameSettings["opening"]): boolean; export declare function initialOpening(settings: GameSettings, opener: Stone, seats: Record): OpeningState; /** * Whether the opening lets the next stone go on `point`. A handicap can add a * pro-style exclusion of its own: the handicapped colour's second stone must * leave the centre, whichever colour opened. */ export declare function openingAllows(state: GameState, point: Point): boolean; /** * The opening state once a stone has landed. A swap protocol pauses for a * decision after its third stone, and again after the fifth if the chooser * extended; the deciding seat is always the one that did not lay the stones. */ export declare function openingAfterMove(state: GameState): OpeningState; /** Whether the game is waiting on a seat to pick a colour. * * @param state - The current immutable game position. * @returns Whether the game is waiting on a seat to pick a colour. * @example * ```ts * import { canChooseColour, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(canChooseColour(state)); * ``` */ export declare function canChooseColour(state: GameState): boolean; /** Swap2 only: the first chooser may add two stones and pass the choice back. * * @param state - The current immutable game position. * @returns Swap2 only: the first chooser may add two stones and pass the choice back. * @example * ```ts * import { canExtendOpening, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(canExtendOpening(state)); * ``` */ export declare function canExtendOpening(state: GameState): boolean; /** * The deciding seat takes `stone`. Seats are exchanged if that colour is not * already theirs; the board and the colour to move are untouched. * * @param state - The current immutable game position. * @param stone - The black or white colour being examined. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { chooseColour, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(chooseColour(state,"black").opening.stage); * ``` */ export declare function chooseColour(state: GameState, stone: Stone): GameState; /** The chooser declines to choose and lays two more stones instead. * * @param state - The current immutable game position. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { createGame, extendOpening } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(extendOpening(state)); * ``` */ export declare function extendOpening(state: GameState): GameState; /** Replays one recorded decision. */ export declare function applyOpeningChoice(state: GameState, choice: OpeningChoice): GameState;