import type { Cell, CheckersRules, GameSettings, GameState, MoveNarrowing, Point, Stone } from "../types.ts"; import type { CheckersMoveResult, Jump } from "./checkers.types.ts"; export type { CheckersMoveResult } from "./checkers.types.ts"; /** * The checkers family: pieces stand on the board from the start and move * diagonally. Capturing is a jump over an enemy piece into an empty square * beyond it, and it is forced — a colour with any capture available may not * play a plain step instead. A piece that captures and can capture again from * where it lands keeps going in the same move. A colour with no legal move, * whether it has no pieces left or every one is shut in, has lost. * * What differs between the games of the family — how many rows of men, whether * a man takes backward, whether a king flies, whether the longest capture must * be chosen, and what crowning does to a capture under way — is the game's * `CheckersRules`, read from its spec. The functions that take a board rather * than a game default to the English rules, which is what they did before the * family had more than one game in it. */ /** Checkers is played on one colour of square only: the board's own dark squares. * * @param point - A zero-based row and column on the board. * @returns Checkers is played on one colour of square only: the board's own dark squares. * @example * ```ts * import { isDarkSquare } from "@johnmorrisdotca/narabe"; * * console.log(isDarkSquare({row:0,col:1})); * ``` */ export declare function isDarkSquare(point: Point): boolean; /** * The rules this game of the family is played by. * * Throws for a game outside the family rather than answering with a default: * a caller asking this of Gomoku is a fault, and English rules handed back * would play a game nobody chose. */ export declare function checkersRulesFor(settings: GameSettings): CheckersRules; /** Every piece on the board when the game starts: `rows` rows of dark squares, each side. */ export declare function checkersStartingPieces(size: number, rows?: number): { point: Point; stone: Stone; }[]; /** Whether the piece at `at`, if any, is a king. * * @param kings - The points occupied by crowned pieces. * @param at - The point to examine. * @returns Whether the piece at `at`, if any, is a king. * @example * ```ts * import { createGame, isKingAt } from "@johnmorrisdotca/narabe"; * * const checkers = createGame({variant:"checkers"}); * console.log(isKingAt(checkers.kings,{row:5,col:0})); * ``` */ export declare function isKingAt(kings: readonly Point[], at: Point): boolean; /** * Where a piece at `from` may step with no capture: an empty diagonal neighbour * forward for a man; for a king, an empty neighbour either way, or — where kings * fly — any empty square along an open diagonal. */ export declare function checkersSteps(board: Cell[], size: number, from: Point, stone: Stone, isKing: boolean, rules?: CheckersRules): Point[]; /** The jumps a piece at `from` may make: the enemy piece taken, and where the jump lands. */ export declare function checkersCaptures(board: Cell[], kings: readonly Point[], size: number, from: Point, stone: Stone, rules?: CheckersRules): Jump[]; /** Whether any of `stone`'s pieces on the board has a capture available right now. * * @param board - The row-major board cells; null marks an empty point. * @param kings - The points occupied by crowned pieces. * @param size - The number of cells on each side of the board. * @param stone - The black or white colour being examined. * @param rules - The draughts rule set governing capture. * @returns Whether any of `stone`'s pieces on the board has a capture available right now. * @example * ```ts * import { ENGLISH_CHECKERS_RULES, checkersHasCapture, createGame } from "@johnmorrisdotca/narabe"; * * const checkers = createGame({variant:"checkers"}); * console.log(checkersHasCapture(checkers.board,checkers.kings,8,"black",ENGLISH_CHECKERS_RULES)); * ``` */ export declare function checkersHasCapture(board: Cell[], kings: readonly Point[], size: number, stone: Stone, rules?: CheckersRules): boolean; /** Whether `stone` has any legal move at all: a capture first, or failing that, a step. */ export declare function checkersHasAnyMove(board: Cell[], kings: readonly Point[], size: number, stone: Stone, rules?: CheckersRules): boolean; /** * Where a piece at `from` may go this move. * * A piece already mid-chain may only continue capturing, and only that piece * may move at all. Otherwise, if any of the colour's pieces can capture, only * a capture is offered, from whichever pieces have one — the forced-capture * rule — narrowed to the longest where the game says so. Failing both, a step. */ export declare function checkersMoves(state: GameState, from: Point): Point[]; /** * Which rule, if any, narrowed the moves the colour to move is offered below * what its pieces could make. * * `capture` when a capture is compulsory: a chain under way, or a capture * anywhere on the board ruling out every step. `mostCaptured` when, beyond that, * the game takes the most and a capture some piece could make was refused * because another takes more. Null when nothing was held back. * * A reading of `legalMoves` against the raw jumps, not a second rule: whatever * the moves are, they were decided above. */ export declare function checkersNarrowing(state: GameState): MoveNarrowing | null; export declare function applyCheckersMove(state: GameState, from: Point, to: Point): CheckersMoveResult;