import type { GameSettings, GameState } from "../types.ts"; /** * Calling a long game a draw. * * Some of these games can run for ever between two careful players — the * misère forms especially, where every stone you place is one fewer safe * point and neither side wants to move. A board that never fills is a game * neither player can leave, and "agree a draw" is not something two people * playing over a week can do easily. * * So a game may be given a length. It is a share of the board's points * rather than a number of moves, which is the whole point of it: one setting * means something sensible on 9×9 and on 19×19 without anybody working * anything out. * * What is counted is moves, not stones. In the games where a turn lays more * than one stone the board fills long before the count is reached, so the * limit simply never bites there — which is right, since those games end on * their own. */ /** * Whether this game can be drawn at all. * * Hex cannot. A full Hex board always holds exactly one chain from side to * side, so there is no position in which neither player has won — and the * rules page says so as a fact about the shape of the board rather than as a * rule anybody wrote. A length that could produce a drawn Hex game would make * that sentence false, so the length simply does not apply there, and the * setting is refused rather than quietly ignored. * * Read from the spec, never from a variant's name: any game that is won by * joining two sides has the same theorem behind it. * * @param settings - The native game settings to interpret. * @returns Whether the native game mechanics can end in a draw. * @example * ```ts * import { canBeDrawn, createGame } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(canBeDrawn(state.settings)); * ``` */ export declare function canBeDrawn(settings: GameSettings): boolean; /** * Whether the board is big enough for a length to mean anything. * * A small board resolves on its own before any share of it has been played. * Ending a game of noughts and crosses after four moves is not a rule anybody * would want; it is this setting misapplied. */ export declare function bigEnoughForLength(settings: GameSettings): boolean; /** * Why this game may not be given a length, or null when it may. * * Two reasons, and they are not the same, so the player is told which: * a game that cannot be drawn at all, and a board too small for a share of it * to arrive before the game is over anyway. */ export declare function lengthReason(settings: GameSettings): "cannot-draw" | "too-small" | null; /** * How many moves may be played before a game nobody has won is a draw, or * null when it is to be played out. * * Rounded down, so "half the board" on an odd board is the smaller half: a * limit that arrives a move early is easier to defend than one that arrives * a move late. * * @param settings - The native game settings to interpret. * @returns The configured move limit, or null when the settings have no applicable length limit. * @example * ```ts * import { createGame, movesBeforeDraw } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(movesBeforeDraw(state.settings)); * ``` */ export declare function movesBeforeDraw(settings: GameSettings): number | null; /** Whether this position has reached the length the players agreed to. */ export declare function reachedDrawLimit(state: GameState): boolean; /** * The state as it stands, or drawn if it has run to its length. * * Applied after a turn is complete rather than after every change: a stone * that owes a quarter turn has not finished its move, and calling that a * draw would leave a board mid-turn for ever. */ export declare function settleDraw(state: GameState): GameState; /** * Whether a finished game was drawn because it ran to its length, rather than * because the board filled or both sides made a line at once. * * The status line has to say which: "both made a line at once" is a different * thing from "we agreed to stop here", and telling a player the wrong one is * worse than telling them nothing. * * @param state - The current immutable game position. * @returns Whether a finished game was drawn because it ran to its length, rather than because the board filled or both sides made a line at once. The status line has to say which: "both made a line at once" is a different thing from "we agreed to stop here", and telling a player the wrong one is worse than telling them nothing. * @example * ```ts * import { createGame, drawnByLength } from "@johnmorrisdotca/narabe"; * * const state = createGame({variant:"freestyle",size:15}); * console.log(drawnByLength(state)); * ``` */ export declare function drawnByLength(state: GameState): boolean;