import type { Cell, GameSettings, GameState, HeadStart, OpeningRule, Stone } from "../types.ts"; /** * The openings these settings may use: what the variant offers, less the * colour-swapping ones when a handicap is bound to a colour — and only the free * opening under a head start. Pro and the renju protocols count stones from the * first, and a head start's free turns and starting pieces are exactly what * that count does not expect. * * @param settings - The native game settings to interpret. * @returns The opening identifiers allowed by the variant, handicap and head-start terms. * @example * ```ts * import { availableOpenings, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(availableOpenings(state.settings)); * ``` */ export declare function availableOpenings(settings: GameSettings): OpeningRule[]; /** * Settings that agree with their variant: a pinned line length wins over the * player's choice, an opening the variant does not offer falls back to free, * and a handicap rules out the openings that swap colours. Applied on creation * so a state can never carry a contradiction. * * @param settings - The native game settings to interpret. * @returns A copy of the settings normalized to the variant, opening and handicap rules. * @example * ```ts * import { createGame, normaliseSettings } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(normaliseSettings(state.settings)); * ``` */ export declare function normaliseSettings(settings: GameSettings): GameSettings; /** * The board a game of these settings begins on: empty, but for the pieces a * variant sets out before anybody moves. * * Lifted out of `createGame` so it can be asked on its own. Which way round a * board should be drawn for the person looking at it is a question about where * their colour starts, and the only honest answer to that is the position * itself — a second list of who begins where would be wrong the first time a * variant disagreed with it. */ export declare function startingBoard(settings: GameSettings): Cell[]; /** * The colour a game must open with whatever anybody asked for, or null where * the players may choose. * * A head start with handicap stones fixes it first: the stones are the given * colour's opening, so the other colour moves — `headStartOpener`. Asked with * the head start and the board it is laid on, which a writer has as well. * * Fixed where the game gives no choice — and then it is the game's own first * colour, which is White for the draughts games whose rules say so — and fixed * under any opening protocol, which always starts from that colour. Asked by * the engine when it builds a game, and by anything that WRITES a game down * before the engine has seen it: a stored opener the engine would overrule is * a row whose seats and names disagree with its own board. * * Null for a variant this deploy does not know, since there is nothing to fix * it to and the caller's own answer is the only one there is. */ export declare function fixedOpener(variant: string, opening: string, start?: { headStart: HeadStart; size: number; }): Stone | null; /** * The colour that opens. `random` is decided by `roll`, a number in [0, 1), * which the caller supplies so this stays pure and testable. Variants that * constrain black, and every opening protocol, put black on move one. * * @param settings - The native game settings to interpret. * @param roll - A random value in [0,1), supplied for reproducible choices. * @returns The colour that opens. `random` is decided by `roll`, a number in [0, 1), which the caller supplies so this stays pure and testable. Variants that constrain black, and every opening protocol, put black on move one. * @example * ```ts * import { createGame, resolveOpener } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(resolveOpener({...state.settings,firstPlayer:"random"}, 0.25)); * ``` */ export declare function resolveOpener(settings: GameSettings, roll?: number): Stone; /** Create an initial immutable position from native settings and an opening roll. * * @param overrides - Optional settings over the native defaults. * @param roll - A random value in [0,1), supplied for reproducible choices. * @returns The resulting position; a refused or inapplicable action leaves the input position unchanged. * @example * ```ts * import { createGame } from "@johnmorrisdotca/narabe"; * * console.log(createGame({variant:"reversi"}).board.length); * ``` */ export declare function createGame(overrides?: Partial, roll?: number): GameState;