/** * js-chess-engine v2 * * Public API for chess game management */ import { BoardConfig, MovesMap, PieceSymbol, HistoryEntry, AIResult } from './types'; export * from './types'; /** * Main Game class - manages chess game state and moves */ export declare class Game { private board; private history; private aiEngine; /** * Create a new game * * @param configuration - Optional board configuration (JSON object, FEN string, or undefined for new game) */ constructor(configuration?: BoardConfig | string); /** * Make a move * * @param from - From square (case-insensitive, e.g., 'E2' or 'e2') * @param to - To square (case-insensitive, e.g., 'E4' or 'e4') * @returns Board configuration after the move */ move(from: string, to: string): BoardConfig; /** * Get all legal moves, optionally filtered by from-square * * @param from - Optional from square to filter moves * @returns Map of from-squares to array of to-squares */ moves(from?: string): MovesMap; /** * Set a piece on a square * * @param square - Square to place piece (case-insensitive) * @param piece - Piece symbol (K, Q, R, B, N, P, k, q, r, b, n, p) */ setPiece(square: string, piece: PieceSymbol): void; /** * Remove a piece from a square * * @param square - Square to remove piece from (case-insensitive) */ removePiece(square: string): void; /** * Get move history * * @returns Array of history entries with board state after each move */ getHistory(): Array; /** * Export current board state as JSON configuration * * @returns Board configuration object */ exportJson(): BoardConfig; /** * Export current board state as FEN string * * @returns FEN string */ exportFEN(): string; /** * Print board to console (Unicode chess pieces) */ printToConsole(): void; /** * Make an AI move (v1 compatible - returns only the move) * * @deprecated Use `ai()` instead. This method will be removed in v3.0.0. * @param level - AI level (1-5, default 3) * @returns The played move object (e.g., {"E2": "E4"}) */ aiMove(level?: number): HistoryEntry; /** * Make an AI move and return both move and board state * * @param options - Optional configuration object * @param options.level - AI difficulty level (1-5, default: 3). Values > 5 are clamped to 5. * @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state. * @param options.ttSizeMB - Transposition table size in MB (0 to disable, min 0.25 MB). Default: auto-scaled by level (e.g., level 3: 2 MB Node.js, 1 MB browser) * @param options.randomness - Centipawn threshold for move variety. The engine picks randomly * among all moves scoring within this many centipawns of the best move. * Makes the engine less predictable without playing blunders. * Default: 0 (fully deterministic). Set to a positive value for variety. * * Reference values: * 0 – fully deterministic (default; same position always plays the same move) * 10 – very subtle (only nearly-identical moves ever swap) * 30 – slight variety (moves within ~½ pawn of best may vary) * 80 – noticeable (moves within ~1½ pawns of best may vary; fun casual play) * 200 – chaotic (may play obviously weaker moves; not recommended) * @returns Object containing the move and board configuration (current state if play=false, updated state if play=true) */ ai(options?: { level?: number; play?: boolean; ttSizeMB?: number; depth?: { base?: number; extended?: number; check?: boolean; quiescence?: number; }; analysis?: boolean; randomness?: number; }): AIResult; private updateConfigStatusFromBoard; } /** * Get all legal moves for a position * * @param config - Board configuration or FEN string * @returns Map of from-squares to array of to-squares */ export declare function moves(config: BoardConfig | string): MovesMap; /** * Get board status * * @param config - Board configuration or FEN string * @returns Board configuration with current status */ export declare function status(config: BoardConfig | string): BoardConfig; /** * Get FEN string for a position * * @param config - Board configuration or FEN string * @returns FEN string */ export declare function getFen(config: BoardConfig | string): string; /** * Make a move on a board * * @param config - Board configuration or FEN string * @param from - From square * @param to - To square * @returns Board configuration after the move */ export declare function move(config: BoardConfig | string, from: string, to: string): BoardConfig; /** * Make an AI move (v1 compatible - returns only the move) * * @deprecated Use `ai()` instead. This function will be removed in v3.0.0. * @param config - Board configuration or FEN string * @param level - AI level (1-5, default 3) * @returns The played move object (e.g., {"E2": "E4"}) */ export declare function aiMove(config: BoardConfig | string, level?: number): HistoryEntry; /** * Make an AI move and return both move and board state * * @param config - Board configuration or FEN string * @param options - Optional configuration object * @param options.level - AI difficulty level (1-5, default: 3) * @param options.play - Whether to apply the move to the game (default: true). If false, only returns the move without modifying game state. * @param options.ttSizeMB - Transposition table size in MB (0 to disable, min 0.25 MB). Default: auto-scaled by level (e.g., level 3: 2 MB Node.js, 1 MB browser) * @returns Object containing the move and board configuration (current state if play=false, updated state if play=true) */ export declare function ai(config: BoardConfig | string, options?: { level?: number; play?: boolean; ttSizeMB?: number; depth?: { base?: number; extended?: number; check?: boolean; quiescence?: number; }; analysis?: boolean; randomness?: number; }): AIResult; //# sourceMappingURL=index.d.ts.map