kokopu
Version:
A JavaScript/TypeScript library implementing the chess game rules and providing tools to read/write the standard chess file formats.
59 lines (58 loc) • 3.37 kB
TypeScript
/*!
* -------------------------------------------------------------------------- *
* *
* Kokopu - A JavaScript/TypeScript chess library. *
* <https://www.npmjs.com/package/kokopu> *
* Copyright (C) 2018-2025 Yoann Le Montagner <yo35 -at- melix.net> *
* *
* Kokopu is free software: you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public License *
* as published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version. *
* *
* Kokopu is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General *
* Public License along with this program. If not, see *
* <http://www.gnu.org/licenses/>. *
* *
* -------------------------------------------------------------------------- */
import { PositionImpl } from './impl';
/**
* Check whether the given position is legal or not.
*
* See {@link Position.isLegal} for the description of the check points enforced in this function.
*/
export declare function isLegal(position: PositionImpl): boolean;
/**
* Refresh the legal flag of the given position if it is set to null
* (which means that the legality state of the position is unknown).
*
* Together with the legal flag, the reference to the squares where the white and
* black kings lie is updated by this function.
*/
export declare function refreshLegalFlagAndKingSquares(position: PositionImpl): void;
/**
* Check whether the current player king is in check after moving from `from` to `to`.
*
* This function implements the verification steps (7) to (9) as defined in {@link isMoveLegal}.
*
* Precondition: {@link refreshLegalFlagAndKingSquares} must have been invoked beforehand.
*
* @param enPassantSquare - Index of the square where the "en-passant" taken pawn lies if any, `-1` otherwise.
*/
export declare function isKingSafeAfterMove(position: PositionImpl, from: number, to: number, enPassantSquare?: number): boolean;
/**
* Refresh the effective castling flags of the given position if they are set to null
* (which means that their states are unknown).
*/
export declare function refreshEffectiveCastling(position: PositionImpl): void;
/**
* Refresh the effective en-passant flag of the given position if it is set to null
* (which means that its state is unknown).
*/
export declare function refreshEffectiveEnPassant(position: PositionImpl): void;
export declare function isEqual(pos1: PositionImpl, pos2: PositionImpl): boolean;