/** * A chess library with move generation and validation, * Polyglot opening book probing, PGN reading and writing, * Gaviota tablebase probing, * Syzygy tablebase probing, and XBoard/UCI engine communication. * * All credit goes to the authors of the python-chess library. * This is a direct port of their excellent library to TypeScript. */ export type RankOrFileIndex = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7; /** Allow the truthy/falsy indexing trick, like `this.occupiedCo[colorIdx(WHITE)]` */ export declare const colorIdx: (color: Color) => 1 | 0; /** ========== Direct transpilation ========== */ export declare const __author__ = "Niklas Fiekas"; export declare const __email__ = "niklas.fiekas@backscattering.de"; export declare const __version__ = "1.10.0"; export declare const __transpilerAuthor__ = "Jackson Thurner Hall"; export declare const __transpiledVersion__ = "0.0.1"; export type EnPassantSpec = 'legal' | 'fen' | 'xfen'; export type Color = boolean; export declare const WHITE: boolean, BLACK: boolean; export declare const COLORS: Color[]; export type ColorName = 'white' | 'black'; export declare const COLOR_NAMES: ColorName[]; export declare const enum PieceType { PAWN = 1, KNIGHT = 2, BISHOP = 3, ROOK = 4, QUEEN = 5, KING = 6 } export declare const PIECE_TYPES: PieceType[]; export declare const PAWN: PieceType, KNIGHT: PieceType, BISHOP: PieceType, ROOK: PieceType, QUEEN: PieceType, KING: PieceType; export declare const PIECE_SYMBOLS: (string | null)[]; export declare const PIECE_NAMES: (string | null)[]; export declare const pieceSymbol: (pieceType: PieceType) => string; export declare const pieceName: (pieceType: PieceType) => string; export declare const UNICODE_PIECE_SYMBOLS: { [key: string]: string; }; export declare const FILE_NAMES: string[]; export declare const RANK_NAMES: string[]; /** The FEN for the standard chess starting position. */ export declare const STARTING_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; /** The board part of the FEN for the standard chess starting position. */ export declare const STARTING_BOARD_FEN = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR"; export declare const enum Status { VALID = 0, NO_WHITE_KING = 1, NO_BLACK_KING = 2, TOO_MANY_KINGS = 4, TOO_MANY_WHITE_PAWNS = 8, TOO_MANY_BLACK_PAWNS = 16, PAWNS_ON_BACKRANK = 32, TOO_MANY_WHITE_PIECES = 64, TOO_MANY_BLACK_PIECES = 128, BAD_CASTLING_RIGHTS = 256, INVALID_EP_SQUARE = 512, OPPOSITE_CHECK = 1024, EMPTY = 2048, RACE_CHECK = 4096, RACE_OVER = 8192, RACE_MATERIAL = 16384, TOO_MANY_CHECKERS = 32768, IMPOSSIBLE_CHECK = 65536 } export declare const STATUS_VALID: Status; export declare const STATUS_NO_WHITE_KING: Status; export declare const STATUS_NO_BLACK_KING: Status; export declare const STATUS_TOO_MANY_KINGS: Status; export declare const STATUS_TOO_MANY_WHITE_PAWNS: Status; export declare const STATUS_TOO_MANY_BLACK_PAWNS: Status; export declare const STATUS_PAWNS_ON_BACKRANK: Status; export declare const STATUS_TOO_MANY_WHITE_PIECES: Status; export declare const STATUS_TOO_MANY_BLACK_PIECES: Status; export declare const STATUS_BAD_CASTLING_RIGHTS: Status; export declare const STATUS_INVALID_EP_SQUARE: Status; export declare const STATUS_OPPOSITE_CHECK: Status; export declare const STATUS_EMPTY: Status; export declare const STATUS_RACE_CHECK: Status; export declare const STATUS_RACE_OVER: Status; export declare const STATUS_RACE_MATERIAL: Status; export declare const STATUS_TOO_MANY_CHECKERS: Status; export declare const STATUS_IMPOSSIBLE_CHECK: Status; /** * Enum with reasons for a game to be over. */ export declare enum Termination { /** See :func:`chess.Board.isCheckmate()`. */ CHECKMATE = 0, /** See :func:`chess.Board.isStalemate()`. */ STALEMATE = 1, /** See :func:`chess.Board.isInsufficientMaterial()`. */ INSUFFICIENT_MATERIAL = 2, /** See :func:`chess.Board.isSeventyfiveMoves()`. */ SEVENTYFIVE_MOVES = 3, /** See :func:`chess.Board.isFivefoldRepetition()`. */ FIVEFOLD_REPETITION = 4, /** See :func:`chess.Board.canClaimFiftyMoves()`. */ FIFTY_MOVES = 5, /** See :func:`chess.Board.canClaimThreefoldRepetition()`. */ THREEFOLD_REPETITION = 6, /** See :func:`chess.Board.isVariantWin()`. */ VARIANT_WIN = 7, /** See :func:`chess.Board.isVariantLoss()`. */ VARIANT_LOSS = 8, /** See :func:`chess.Board.isVariantDraw()`. */ VARIANT_DRAW = 9 } /** * Information about the outcome of an ended game, usually obtained from * :func:`chess.Board.outcome()`. */ export declare class Outcome { termination: Termination; /** The reason for the game to have ended. */ winner: Color | null; /** The winning color or ``null`` if drawn. */ constructor(termination: Termination, winner: Color | null); /** * Returns ``1-0``, ``0-1`` or ``1/2-1/2``. */ result(): '1-0' | '0-1' | '1/2-1/2'; } /** * Raised when move notation is not syntactically valid */ export declare class InvalidMoveError extends Error { constructor(message?: string); } /** * Raised when the attempted move is illegal in the current position */ export declare class IllegalMoveError extends Error { constructor(message?: string); } /** * Raised when the attempted move is ambiguous in the current position */ export declare class AmbiguousMoveError extends Error { constructor(message?: string); } export declare const enum Square { A1 = 0, B1 = 1, C1 = 2, D1 = 3, E1 = 4, F1 = 5, G1 = 6, H1 = 7, A2 = 8, B2 = 9, C2 = 10, D2 = 11, E2 = 12, F2 = 13, G2 = 14, H2 = 15, A3 = 16, B3 = 17, C3 = 18, D3 = 19, E3 = 20, F3 = 21, G3 = 22, H3 = 23, A4 = 24, B4 = 25, C4 = 26, D4 = 27, E4 = 28, F4 = 29, G4 = 30, H4 = 31, A5 = 32, B5 = 33, C5 = 34, D5 = 35, E5 = 36, F5 = 37, G5 = 38, H5 = 39, A6 = 40, B6 = 41, C6 = 42, D6 = 43, E6 = 44, F6 = 45, G6 = 46, H6 = 47, A7 = 48, B7 = 49, C7 = 50, D7 = 51, E7 = 52, F7 = 53, G7 = 54, H7 = 55, A8 = 56, B8 = 57, C8 = 58, D8 = 59, E8 = 60, F8 = 61, G8 = 62, H8 = 63 } export declare const SQUARES: Square[]; export declare const A1: Square, B1: Square, C1: Square, D1: Square, E1: Square, F1: Square, G1: Square, H1: Square, A2: Square, B2: Square, C2: Square, D2: Square, E2: Square, F2: Square, G2: Square, H2: Square, A3: Square, B3: Square, C3: Square, D3: Square, E3: Square, F3: Square, G3: Square, H3: Square, A4: Square, B4: Square, C4: Square, D4: Square, E4: Square, F4: Square, G4: Square, H4: Square, A5: Square, B5: Square, C5: Square, D5: Square, E5: Square, F5: Square, G5: Square, H5: Square, A6: Square, B6: Square, C6: Square, D6: Square, E6: Square, F6: Square, G6: Square, H6: Square, A7: Square, B7: Square, C7: Square, D7: Square, E7: Square, F7: Square, G7: Square, H7: Square, A8: Square, B8: Square, C8: Square, D8: Square, E8: Square, F8: Square, G8: Square, H8: Square; export declare const SQUARE_NAMES: string[]; /** * Gets the square index for the given square *name* * (e.g., ``a1`` returns ``0``). * * @throws :exc:`Error` if the square name is invalid. */ export declare const parseSquare: (name: string) => Square; /** * Gets the name of the square, like ``a3``. */ export declare const squareName: (square: Square) => string; /** * Gets a square number by file and rank index. */ export declare const square: (fileIndex: RankOrFileIndex, rankIndex: RankOrFileIndex) => Square; /** * Gets the file index of the square where ``0`` is the a-file. */ export declare const squareFile: (square: Square) => RankOrFileIndex; /** * Gets the rank index of the square where ``0`` is the first rank. */ export declare const squareRank: (square: Square) => RankOrFileIndex; /** * Gets the Chebyshev distance (i.e., the number of king steps) from square *a* to *b*. */ export declare const squareDistance: (a: Square, b: Square) => number; /** * Gets the Manhattan/Taxicab distance (i.e., the number of orthogonal king steps) from square *a* to *b*. */ export declare const squareManhattanDistance: (a: Square, b: Square) => number; /** * Gets the Knight distance (i.e., the number of knight moves) from square *a* to *b*. */ export declare const squareKnightDistance: (a: Square, b: Square) => number; /** * Mirrors the square vertically. */ export declare const squareMirror: (square: Square) => Square; export declare const SQUARES_180: Square[]; export type Bitboard = bigint; export declare const BB_EMPTY = 0n; export declare const BB_ALL = 18446744073709551615n; export declare const BB_SQUARES: bigint[]; export declare const BB_A1: bigint, BB_B1: bigint, BB_C1: bigint, BB_D1: bigint, BB_E1: bigint, BB_F1: bigint, BB_G1: bigint, BB_H1: bigint, BB_A2: bigint, BB_B2: bigint, BB_C2: bigint, BB_D2: bigint, BB_E2: bigint, BB_F2: bigint, BB_G2: bigint, BB_H2: bigint, BB_A3: bigint, BB_B3: bigint, BB_C3: bigint, BB_D3: bigint, BB_E3: bigint, BB_F3: bigint, BB_G3: bigint, BB_H3: bigint, BB_A4: bigint, BB_B4: bigint, BB_C4: bigint, BB_D4: bigint, BB_E4: bigint, BB_F4: bigint, BB_G4: bigint, BB_H4: bigint, BB_A5: bigint, BB_B5: bigint, BB_C5: bigint, BB_D5: bigint, BB_E5: bigint, BB_F5: bigint, BB_G5: bigint, BB_H5: bigint, BB_A6: bigint, BB_B6: bigint, BB_C6: bigint, BB_D6: bigint, BB_E6: bigint, BB_F6: bigint, BB_G6: bigint, BB_H6: bigint, BB_A7: bigint, BB_B7: bigint, BB_C7: bigint, BB_D7: bigint, BB_E7: bigint, BB_F7: bigint, BB_G7: bigint, BB_H7: bigint, BB_A8: bigint, BB_B8: bigint, BB_C8: bigint, BB_D8: bigint, BB_E8: bigint, BB_F8: bigint, BB_G8: bigint, BB_H8: bigint; export declare const BB_CORNERS: bigint; export declare const BB_CENTER: bigint; export declare const BB_LIGHT_SQUARES = 6172840429334713770n; export declare const BB_DARK_SQUARES = 12273903644374837845n; export declare const BB_FILES: bigint[]; export declare const BB_FILE_A: bigint, BB_FILE_B: bigint, BB_FILE_C: bigint, BB_FILE_D: bigint, BB_FILE_E: bigint, BB_FILE_F: bigint, BB_FILE_G: bigint, BB_FILE_H: bigint; export declare const BB_RANKS: bigint[]; export declare const BB_RANK_1: bigint, BB_RANK_2: bigint, BB_RANK_3: bigint, BB_RANK_4: bigint, BB_RANK_5: bigint, BB_RANK_6: bigint, BB_RANK_7: bigint, BB_RANK_8: bigint; export declare const BB_BACKRANKS: bigint; export declare const lsb: (bb: Bitboard) => Square; export declare function scanForward(bb: Bitboard): IterableIterator; export declare const msb: (bb: Bitboard) => Square; export declare function scanReversed(bb: Bitboard): IterableIterator; export declare const popcount: (bb: Bitboard) => number; export declare const flipVertical: (bb: Bitboard) => Bitboard; export declare const flipHorizontal: (bb: Bitboard) => Bitboard; export declare const flipDiagonal: (bb: Bitboard) => Bitboard; export declare const flipAntiDiagonal: (bb: Bitboard) => Bitboard; export declare const shiftDown: (b: Bitboard) => Bitboard; export declare const shift2Down: (b: Bitboard) => Bitboard; export declare const shiftUp: (b: Bitboard) => Bitboard; export declare const shift2Up: (b: Bitboard) => Bitboard; export declare const shiftRight: (b: Bitboard) => Bitboard; export declare const shift2Right: (b: Bitboard) => Bitboard; export declare const shiftLeft: (b: Bitboard) => Bitboard; export declare const shift2Left: (b: Bitboard) => Bitboard; export declare const shiftUpLeft: (b: Bitboard) => Bitboard; export declare const shiftUpRight: (b: Bitboard) => Bitboard; export declare const shiftDownLeft: (b: Bitboard) => Bitboard; export declare const shiftDownRight: (b: Bitboard) => Bitboard; export declare const _slidingAttacks: (square: Square, occupied: Bitboard, deltas: number[]) => bigint; export declare const _stepAttacks: (square: Square, deltas: number[]) => Bitboard; export declare const BB_KNIGHT_ATTACKS: bigint[]; export declare const BB_KING_ATTACKS: bigint[]; export declare const BB_PAWN_ATTACKS: bigint[][]; export declare const _edges: (square: Square) => Bitboard; export declare function _carryRippler(mask: Bitboard): IterableIterator; export declare const _attackTable: (deltas: number[]) => [Bitboard[], Map[]]; export declare const BB_DIAG_MASKS: bigint[], BB_DIAG_ATTACKS: Map[]; export declare const BB_FILE_MASKS: bigint[], BB_FILE_ATTACKS: Map[]; export declare const BB_RANK_MASKS: bigint[], BB_RANK_ATTACKS: Map[]; export declare const _rays: () => Bitboard[][]; export declare const BB_RAYS: bigint[][]; export declare const ray: (a: Square, b: Square) => Bitboard; export declare const between: (a: Square, b: Square) => Bitboard; export declare const SAN_REGEX: RegExp; export declare const FEN_CASTLING_REGEX: RegExp; /** * A piece with type and color. */ export declare class Piece { /** The piece type. */ pieceType: PieceType; /** The piece color. */ color: Color; constructor(pieceType: PieceType, color: Color); /** * Gets the symbol ``P``, ``N``, ``B``, ``R``, ``Q`` or ``K`` for white * pieces or the lower-case variants for the black pieces. */ symbol(): string; /** * Gets the Unicode character for the piece. */ unicodeSymbol({ invertColor }?: { invertColor: boolean; }): string; hash(): number; toString(): string; toRepr(): string; _reprSvg_(): string; static fromSymbol(symbol: string): Piece; } /** * Represents a move from a square to a square and possibly the promotion * piece type. * * Drops and null moves are supported. */ export declare class Move { /** The source square. */ fromSquare: Square; /** The target square. */ toSquare: Square; /** The promotion piece type or ``null``. */ promotion: PieceType | null; /** The drop piece type or ``null``. */ drop: PieceType | null; constructor(fromSquare: Square, toSquare: Square, { promotion, drop, }?: { promotion?: PieceType | null; drop?: PieceType | null; }); /** * Gets a UCI string for the move. * * For example, a move from a7 to a8 would be ``a7a8`` or ``a7a8q`` * (if the latter is a promotion to a queen). * * The UCI representation of a null move is ``0000``. */ uci(): string; xboard(): string; bool(): boolean; toRepr(): string; toString(): string; copy(): Move; equals(other: any): boolean; static equals(a: Move, b: Move): boolean; /** * Parses a UCI string. * * @thrwos :exc:`InvalidMoveError` if the UCI string is invalid. */ static fromUci(uci: string): Move; /** * Gets a null move. * * A null move just passes the turn to the other side (and possibly * forfeits en passant capturing). Null moves evaluate to ``False`` in * boolean contexts. * * >>> import chess * >>> * >>> bool(chess.Move.null()) * False */ static null(): Move; } /** * A board representing the position of chess pieces. See * :class:`~chess.Board` for a full board with move generation. * * The board is initialized with the standard chess starting position, unless * otherwise specified in the optional *boardFen* argument. If *boardFen* * is ``null``, an empty board is created. */ export declare class BaseBoard { occupied: Bitboard; occupiedCo: [Bitboard, Bitboard]; pawns: Bitboard; knights: Bitboard; bishops: Bitboard; rooks: Bitboard; queens: Bitboard; kings: Bitboard; promoted: Bitboard; constructor(boardFen?: string | null); _resetBoard(): void; /** * Resets pieces to the starting position. * * :class:`~chess.Board` also resets the move stack, but not turn, * castling rights and move counters. Use :func:`chess.Board.reset()` to * fully restore the starting position. */ resetBoard(): void; _clearBoard(): void; /** * Clears the board. * * :class:`~chess.Board` also clears the move stack. */ clearBoard(): void; piecesMask(pieceType: PieceType, color: Color): Bitboard; /** * Gets pieces of the given type and color. * * Returns a :class:`set of squares `. */ pieces(pieceType: PieceType, color: Color): SquareSet; /** * Gets the :class:`piece ` at the given square. */ pieceAt(square: Square): Piece | null; /** * Gets the piece type at the given square. */ pieceTypeAt(square: Square): PieceType | null; /** * Gets the color of the piece at the given square. */ colorAt(square: Square): Color | null; /** * Finds the king square of the given side. Returns ``null`` if there * is no king of that color. * * In variants with king promotions, only non-promoted kings are * considered. */ king(color: Color): Square | null; attacksMask(square: Square): Bitboard; /** * Gets the set of attacked squares from the given square. * * There will be no attacks if the square is empty. Pinned pieces are * still attacking other squares. * * Returns a :class:`set of squares `. */ attacks(square: Square): SquareSet; _attackersMask(color: Color, square: Square, occupied: Bitboard): Bitboard; attackersMask(color: Color, square: Square): Bitboard; /** * Checks if the given side attacks the given square. * * Pinned pieces still count as attackers. Pawns that can be captured * en passant are **not** considered attacked. */ isAttackedBy(color: Color, square: Square): boolean; /** * Gets the set of attackers of the given color for the given square. * * Pinned pieces still count as attackers. * * Returns a :class:`set of squares `. */ attackers(color: Color, square: Square): SquareSet; pinMask(color: Color, square: Square): Bitboard; /** * Detects an absolute pin (and its direction) of the given square to * the king of the given color. * * >>> import chess * >>> * >>> board = chess.Board("rnb1k2r/ppp2ppp/5n2/3q4/1b1P4/2N5/PP3PPP/R1BQKBNR w KQkq - 3 7") * >>> board.isPinned(chess.WHITE, chess.C3) * True * >>> direction = board.pin(chess.WHITE, chess.C3) * >>> direction * SquareSet(0x0000_0001_0204_0810) * >>> print(direction) * . . . . . . . . * . . . . . . . . * . . . . . . . . * 1 . . . . . . . * . 1 . . . . . . * . . 1 . . . . . * . . . 1 . . . . * . . . . 1 . . . * * Returns a :class:`set of squares ` that mask the rank, * file or diagonal of the pin. If there is no pin, then a mask of the * entire board is returned. */ pin(color: Color, square: Square): SquareSet; /** * Detects if the given square is pinned to the king of the given color. */ isPinned(color: Color, square: Square): boolean; _removePieceAt(square: Square): PieceType | null; /** * Removes the piece from the given square. Returns the * :class:`Piece` or `null` if the square was already empty. * * :class:`Board` also clears the move stack. */ removePieceAt(square: Square): Piece | null; _setPieceAt(square: Square, pieceType: PieceType, color: Color, promoted?: boolean): void; /** * Sets a piece at the given square. * * An existing piece is replaced. Setting *piece* to `null` is * equivalent to :func:`~chess.Board.removePieceAt()`. * * :class:`~chess.Board` also clears the move stack. */ setPieceAt(square: Square, piece: Piece | null, promoted?: boolean): void; /** * Gets the board FEN (e.g., * ``rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR``). */ boardFen({ promoted }?: { promoted?: boolean | null; }): string; _setBoardFen(fen: string): void; /** * Parses *fen* and sets up the board, where *fen* is the board part of * a FEN. * * :class:`~chess.Board` also clears the move stack. * * @throws Error if syntactically invalid. */ setBoardFen(fen: string): void; /** * Gets a dictionary of :class:`pieces ` by square index. */ pieceMap({ mask }?: { mask?: Bitboard; }): Map; _setPieceMap(pieceMap: Map): void; /** * Sets up the board from a dictionary of :class:`pieces ` * by square index. * * :class:`~chess.Board` also clears the move stack. */ setPieceMap(pieceMap: Map): void; _setChess960Pos(scharnagl: number): void; /** * Sets up a Chess960 starting position given its index between 0 and 959. * Also see :func:`~chess.BaseBoard.fromChess960Pos()`. */ setChess960Pos(scharnagl: number): void; /** * Gets the Chess960 starting position index between 0 and 959, * or ``None``. */ chess960Pos(): number | null; toRepr(): string; toString(): string; /** * Returns a string representation of the board with Unicode pieces. * Useful for pretty-printing to a terminal. * * @param invertColor: Invert color of the Unicode pieces. * @param borders: Show borders and a coordinate margin. */ unicode({ invertColor, borders, emptySquare, orientation, }?: { invertColor?: boolean; borders?: boolean; emptySquare?: string; orientation?: Color; }): string; _reprSvg(): string; equals(other: any): boolean; applyTransform(f: (board: Bitboard) => Bitboard): void; /** * Returns a transformed copy of the board (without move stack) * by applying a bitboard transformation function. * * Available transformations include :func:`chess.flipVertical()`, * :func:`chess.flipHorizontal()`, :func:`chess.flipDiagonal()`, * :func:`chess.flipAntiDiagonal()`, :func:`chess.shiftDown()`, * :func:`chess.shiftUp()`, :func:`chess.shiftLeft()`, and * :func:`chess.shiftRight()`. * * Alternatively, :func:`~chess.BaseBoard.applyTransform()` can be used * to apply the transformation on the board. */ transform(f: (board: Bitboard) => Bitboard): this; applyMirror(): void; /** * Returns a mirrored copy of the board (without move stack). * * The board is mirrored vertically and piece colors are swapped, so that * the position is equivalent modulo color. * * Alternatively, :func:`~chess.BaseBoard.applyMirror()` can be used * to mirror the board. */ mirror(): this; /** * Creates a copy of the board. */ copy(): this; /** * Creates a new empty board. Also see * :func:`~chess.BaseBoard.clearBoard()`. */ static empty(): BaseBoard; /** * Creates a new board, initialized with a Chess960 starting position. * * >>> import chess * >>> import random * >>> * >>> board = chess.Board.fromChess960Pos(random.randint(0, 959)) */ static fromChess960Pos(scharnagl: number): BaseBoard; } export declare class _BoardState { pawns: Bitboard; knights: Bitboard; bishops: Bitboard; rooks: Bitboard; queens: Bitboard; kings: Bitboard; occupiedW: Bitboard; occupiedB: Bitboard; occupied: Bitboard; promoted: Bitboard; turn: Color; castlingRights: Bitboard; epSquare: Square | null; halfmoveClock: number; fullmoveNumber: number; constructor(board: BoardT); restore(board: BoardT): void; } /** * A :class:`~chess.BaseBoard`, additional information representing * a chess position, and a :data:`move stack `. * * Provides :data:`move generation `, validation, * :func:`parsing `, attack generation, * :func:`game end detection `, * and the capability to :func:`make ` and * :func:`unmake ` moves. * * The board is initialized to the standard chess starting position, * unless otherwise specified in the optional *fen* argument. * If *fen* is ``None``, an empty board is created. * * Optionally supports *chess960*. In Chess960, castling moves are encoded * by a king move to the corresponding rook square. * Use :func:`chess.Board.fromChess960Pfos()` to create a board with one * of the Chess960 starting positions. * * It's safe to set :data:`~Board.turn`, :data:`~Board.castlingRights`, * :data:`~Board.epSquare`, :data:`~Board.halfmoveClock` and * :data:`~Board.fullmoveNumber` directly. * * .. warning:: * It is possible to set up and work with invalid positions. In this * case, :class:`~chess.Board` implements a kind of "pseudo-chess" * (useful to gracefully handle errors or to implement chess variants). * Use :func:`~chess.Board.isValid()` to detect invalid positions. */ export declare class Board extends BaseBoard { static aliases: string[]; static uciVariant: string | null; static xboardVariant: string | null; static startingFen: string; static tbwSuffix: string | null; static tbzSuffix: string | null; static tbwMagic: Uint8Array | null; static tbzMagic: Uint8Array | null; static pawnlessTbwSuffix: string | null; static pawnlessTbzSuffix: string | null; static pawnlessTbwMagic: Uint8Array | null; static pawnlessTbzMagic: Uint8Array | null; static connectedKings: boolean; static oneKing: boolean; static capturesCompulsory: boolean; /** The side to move (``chess.WHITE`` or ``chess.BLACK``). */ turn: Color; /** * Bitmask of the rooks with castling rights. * * To test for specific squares: * * >>> import chess * >>> * >>> board = chess.Board() * >>> bool(board.castlingRights & chess.BB_H1) // White can castle with the h1 rook * True * * To add a specific square: * * >>> board.castlingRights |= chess.BB_A1 * * Use :func:`~chess.Board.setCastlingFen()` to set multiple castling * rights. Also see :func:`~chess.Board.hasCastlingRights()`, * :func:`~chess.Board.hasKingsideCastlingRights()`, * :func:`~chess.Board.hasQueensideCastlingRights()`, * :func:`~chess.Board.hasChess960CastlingRights()`, * :func:`~chess.Board.cleanCastlingRights()`. */ castlingRights: Bitboard; /** * The potential en passant square on the third or sixth rank or ``null``. * * Use :func:`~chess.Board.hasLegalEnPassant()` to test if en passant * capturing would actually be possible on the next move. */ epSquare: Square | null; /** * Counts move pairs. Starts at `1` and is incremented after every move * of the black side. */ fullmoveNumber: number; /** The number of half-moves since the last capture or pawn move. */ halfmoveClock: number; /** A bitmask of pieces that have been promoted. */ promoted: Bitboard; /** * Whether the board is in Chess960 mode. In Chess960 castling moves are * represented as king moves to the corresponding rook square. */ chess960: boolean; /** * The move stack. Use :func:`Board.push() `, * :func:`Board.pop() `, * :func:`Board.peek() ` and * :func:`Board.clearStack() ` for * manipulation. */ moveStack: Move[]; _stack: _BoardState[]; constructor(fen?: string | null, { chess960 }?: { chess960?: boolean; }); /** * A dynamic list of legal moves. * * >>> import chess * >>> * >>> board = chess.Board() * >>> board.legalMoves.count() * 20 * >>> bool(board.legalMoves) * True * >>> move = chess.Move.fromUci("g1f3") * >>> move in board.legalMoves * True * * Wraps :func:`~chess.Board.generateLegalMoves()` and * :func:`~chess.Board.isLegal()`. */ get legalMoves(): LegalMoveGenerator; /** * A dynamic list of pseudo-legal moves, much like the legal move list. * * Pseudo-legal moves might leave or put the king in check, but are * otherwise valid. Null moves are not pseudo-legal. Castling moves are * only included if they are completely legal. * * Wraps :func:`~chess.Board.generatePseudoLegalMoves()` and * :func:`~chess.Board.isPseudoLegal()`. */ get pseudoLegalMoves(): PseudoLegalMoveGenerator; /** * Restores the starting position. */ reset(): void; resetBoard(): void; /** * Clears the board. * * Resets move stack and move counters. The side to move is white. There * are no rooks or kings, so castling rights are removed. * * In order to be in a valid :func:`~chess.Board.status()`, at least kings * need to be put on the board. */ clear(): void; clearBoard(): void; /** * Clears the move stack. */ clearStack(): void; /** * Returns a copy of the root position. */ root(this: InstanceType): InstanceType; /** * Returns the number of half-moves since the start of the game, as * indicated by :data:`~chess.Board.fullmoveNumber` and * :data:`~chess.Board.turn`. * * If moves have been pushed from the beginning, this is usually equal to * ``len(board.moveStack)``. But note that a board can be set up with * arbitrary starting positions, and the stack can be cleared. */ ply(): number; removePieceAt(square: Square): Piece | null; setPieceAt(square: Square, piece: Piece | null, promoted?: boolean): void; generatePseudoLegalMoves(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; generatePseudoLegalEp(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; generatePseudoLegalCaptures(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; checkersMask(): Bitboard; /** * Gets the pieces currently giving check. * * Returns a :class:`set of squares `. */ checkers(): SquareSet; isCheck(): boolean; givesCheck(move: Move): boolean; isIntoCheck(move: Move): boolean; wasIntoCheck(): boolean; isPseudoLegal(move: Move): boolean; isLegal(move: Move): boolean; /** * Checks if the game is over due to a special variant end condition. * * Note, for example, that stalemate is not considered a variant-specific * end condition (this method will return ``False``), yet it can have a * special **result** in suicide chess (any of * :func:`~chess.Board.isVariantLoss()`, * :func:`~chess.Board.isVariantWin()`, * :func:`~chess.Board.isVariantDraw()` might return ``True``). */ isVariantEnd(): boolean; /** * Checks if the current side to move lost due to a variant-specific * condition. */ isVariantLoss(): boolean; /** * Checks if the current side to move won due to a variant-specific * condition. */ isVariantWin(): boolean; /** * Checks if a variant-specific drawing condition is fulfilled. */ isVariantDraw(): boolean; isGameOver({ claimDraw }?: { claimDraw?: boolean; }): boolean; result({ claimDraw }?: { claimDraw?: boolean; }): string; /** * Checks if the game is over due to * :func:`checkmate `, * :func:`stalemate `, * :func:`insufficient material `, * the :func:`seventyfive-move rule `, * :func:`fivefold repetition `, * or a :func:`variant end condition `. * Returns the :class:`chess.Outcome` if the game has ended, otherwise * ``None``. * * Alternatively, use :func:`~chess.Board.isGameOver()` if you are not * interested in who won the game and why. * * The game is not considered to be over by the * :func:`fifty-move rule ` or * :func:`threefold repetition `, * unless *claimDraw* is given. Note that checking the latter can be * slow. */ outcome({ claimDraw }?: { claimDraw?: boolean; }): Outcome | null; /** * Checks if the current position is a checkmate. */ isCheckmate(): boolean; /** * Checks if the current position is a stalemate. */ isStalemate(): boolean; /** * Checks if neither side has sufficient winning material * (:func:`~chess.Board.hasInsufficientMaterial()`). */ isInsufficientMaterial(): boolean; /** * Checks if *color* has insufficient winning material. * * This is guaranteed to return ``False`` if *color* can still win the * game. * * The converse does not necessarily hold: * The implementation only looks at the material, including the colors * of bishops, but not considering piece positions. So fortress * positions or positions with forced lines may return ``False``, even * though there is no possible winning line. */ hasInsufficientMaterial(color: Color): boolean; _isHalfmoves(n: number): boolean; /** * Since the 1st of July 2014, a game is automatically drawn (without * a claim by one of the players) if the half-move clock since a capture * or pawn move is equal to or greater than 150. Other means to end a game * take precedence. */ isSeventyfiveMoves(): boolean; /** * Since the 1st of July 2014 a game is automatically drawn (without * a claim by one of the players) if a position occurs for the fifth time. * Originally this had to occur on consecutive alternating moves, but * this has since been revised. */ isFivefoldRepetition(): boolean; /** * Checks if the player to move can claim a draw by the fifty-move rule or * by threefold repetition. * * Note that checking the latter can be slow. */ canClaimDraw(): boolean; /** * Checks that the clock of halfmoves since the last capture or pawn move * is greater or equal to 100, and that no other means of ending the game * (like checkmate) take precedence. */ isFiftyMoves(): boolean; /** * Checks if the player to move can claim a draw by the fifty-move rule. * * In addition to :func:`~chess.Board.isFiftyMoves()`, the fifty-move * rule can also be claimed if there is a legal move that achieves this * condition. */ canClaimFiftyMoves(): boolean; /** * Checks if the player to move can claim a draw by threefold repetition. * * Draw by threefold repetition can be claimed if the position on the * board occurred for the third time or if such a repetition is reached * with one of the possible legal moves. * * Note that checking this can be slow: In the worst case * scenario, every legal move has to be tested and the entire game has to * be replayed because there is no incremental transposition table. */ canClaimThreefoldRepetition(): boolean; /** * Checks if the current position has repeated 3 (or a given number of) * times. * * Unlike :func:`~chess.Board.canClaimThreefoldRepetition()`, * this does not consider a repetition that can be played on the next * move. * * Note that checking this can be slow: In the worst case, the entire * game has to be replayed because there is no incremental transposition * table. */ isRepetition(count?: number): boolean; _boardState(): _BoardState; _pushCapture(move: Move, captureSquare: Square, pieceType: PieceType, wasPromoted: boolean): void; /** * Updates the position with the given *move* and puts it onto the * move stack. * * >>> import chess * >>> * >>> board = chess.Board() * >>> * >>> Nf3 = chess.Move.fromUci("g1f3") * >>> board.push(Nf3) # Make the move * * >>> board.pop() # Unmake the last move * Move.fromUci('g1f3') * * Null moves just increment the move counters, switch turns and forfeit * en passant capturing. * * .. warning:: * Moves are not checked for legality. It is the caller's * responsibility to ensure that the move is at least pseudo-legal or * a null move. */ push(move: Move): void; /** * Restores the previous position and returns the last move from the stack. * * @throws :exc:`IndexError` if the move stack is empty. */ pop(): Move; /** * Gets the last move from the move stack. * * @throws :exc:`IndexError` if the move stack is empty. */ peek(): Move; /** * Finds a matching legal move for an origin square, a target square, and * an optional promotion piece type. * * For pawn moves to the backrank, the promotion piece type defaults to * :data:`chess.QUEEN`, unless otherwise specified. * * Castling moves are normalized to king moves by two steps, except in * Chess960. * * @throws :exc:`IllegalMoveError` if no matching legal move is found. */ findMove(fromSquare: Square, toSquare: Square, promotion?: PieceType | null): Move; castlingShredderFen(): string; castlingXfen(): string; /** * Checks if there is a pseudo-legal en passant capture. */ hasPseudoLegalEnPassant(): boolean; /** * Checks if there is a legal en passant capture. */ hasLegalEnPassant(): boolean; /** * Gets a FEN representation of the position. * * A FEN string (e.g., * ``rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1``) consists * of the board part :func:`~chess.Board.boardFen()`, the * :data:`~chess.Board.turn`, the castling part * (:data:`~chess.Board.castlingRights`), * the en passant square (:data:`~chess.Board.epSquare`), * the :data:`~chess.Board.halfmoveClock` * and the :data:`~chess.Board.fullmoveNumber`. * * :param shredder: Use :func:`~chess.Board.castlingShredderFen()` * and encode castling rights by the file of the rook * (like ``HAha``) instead of the default * :func:`~chess.Board.castlingXfen()` (like ``KQkq``). * :param enPassant: By default, only fully legal en passant squares * are included (:func:`~chess.Board.hasLegalEnPassant()`). * Pass ``fen`` to strictly follow the FEN specification * (always include the en passant square after a two-step pawn move) * or ``xfen`` to follow the X-FEN specification * (:func:`~chess.Board.hasPseudoLegalEnPassant()`). * :param promoted: Mark promoted pieces like ``Q~``. By default, this is * only enabled in chess variants where this is relevant. */ fen({ shredder, enPassant, promoted, }?: { shredder?: boolean; enPassant?: EnPassantSpec; promoted?: boolean | null; }): string; shredderFen({ enPassant, promoted, }?: { enPassant?: EnPassantSpec; promoted?: boolean | null; }): string; /** * Parses a FEN and sets the position from it. * * :raises: :exc:`ValueError` if syntactically invalid. Use * :func:`~chess.Board.isValid()` to detect invalid positions. */ setFen(fen: string): void; _setCastlingFen(castlingFen: string): void; /** * Sets castling rights from a string in FEN notation like ``Qqk``. * * Also clears the move stack. * * :raises: :exc:`ValueError` if the castling FEN is syntactically * invalid. */ setCastlingFen(castlingFen: string): void; setBoardFen(fen: string): void; setPieceMap(pieces: Map): void; setChess960Pos(scharnagl: number): void; /** * Gets the Chess960 starting position index between 0 and 956, * or ``None`` if the current position is not a Chess960 starting * position. * * By default, white to move (**ignoreTurn**) and full castling rights * (**ignoreCastling**) are required, but move counters * (**ignoreCounters**) are ignored. */ chess960Pos({ ignoreTurn, ignoreCastling, ignoreCounters, }?: { ignoreTurn?: boolean; ignoreCastling?: boolean; ignoreCounters?: boolean; }): number | null; _epdOperations(operations: Map>): string; /** * Gets an EPD representation of the current position. * * See :func:`~chess.Board.fen()` for FEN formatting options (*shredder*, * *epSquare* and *promoted*). * * EPD operations can be given as keyword arguments. Supported operands * are strings, integers, finite floats, legal moves and ``None``. * Additionally, the operation ``pv`` accepts a legal variation as * a list of moves. The operations ``am`` and ``bm`` accept a list of * legal moves in the current position. * * The name of the field cannot be a lone dash and cannot contain spaces, * newlines, carriage returns or tabs. * * *hmvc* and *fmvn* are not included by default. You can use: * * >>> import chess * >>> * >>> board = chess.Board() * >>> board.epd(hmvc=board.halfmoveClock, fmvn=board.fullmoveNumber) * 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - hmvc 0; fmvn 1;' */ epd({ shredder, enPassant, promoted, }?: { shredder?: boolean; enPassant?: EnPassantSpec; promoted?: boolean | null; }, operations?: Map>): string; _parseEpdOps(operationPart: string, makeBoard: () => T): Map; /** * Parses the given EPD string and uses it to set the position. * * If present, ``hmvc`` and ``fmvn`` are used to set the half-move * clock and the full-move number. Otherwise, ``0`` and ``1`` are used. * * Returns a dictionary of parsed operations. Values can be strings, * integers, floats, move objects, or lists of moves. * * :raises: :exc:`ValueError` if the EPD string is invalid. */ setEpd(epd: string): Map; /** * Gets the standard algebraic notation of the given move in the context * of the current position. */ san(move: Move): string; /** * Gets the long algebraic notation of the given move in the context of * the current position. */ lan(move: Move): string; sanAndPush(move: Move): string; _algebraic(move: Move, { long }?: { long?: boolean; }): string; _algebraicAndPush(move: Move, { long }?: { long?: boolean; }): string; _algebraicWithoutSuffix(move: Move, { long }?: { long?: boolean; }): string; /** * Given a sequence of moves, returns a string representing the sequence * in standard algebraic notation (e.g., ``1. e4 e5 2. Nf3 Nc6`` or * ``37...Bg6 38. fxg6``). * * The board will not be modified as a result of calling this. * * :raises: :exc:`IllegalMoveError` if any moves in the sequence are illegal. */ variationSan(variation: Iterable): string; /** * Uses the current position as the context to parse a move in standard * algebraic notation and returns the corresponding move object. * * Ambiguous moves are rejected. Overspecified moves (including long * algebraic notation) are accepted. Some common syntactical deviations * are also accepted. * * The returned move is guaranteed to be either legal or a null move. * * @throws :exc:Error if the SAN is invalid, illegal or ambiguous. * - `InvalidMoveError` if the SAN is syntactically invalid. * - `IllegalMoveError` if the SAN is illegal. * - `AmbiguousMoveError` if the SAN is ambiguous. */ parseSan(san: string): Move; /** * Parses a move in standard algebraic notation, makes the move and puts * it onto the move stack. * * Returns the move. * * :raises: * :exc:`ValueError` (specifically an exception specified below) if neither legal nor a null move. * * - :exc:`InvalidMoveError` if the SAN is syntactically invalid. * - :exc:`IllegalMoveError` if the SAN is illegal. * - :exc:`AmbiguousMoveError` if the SAN is ambiguous. */ pushSan(san: string): Move; /** * Gets the UCI notation of the move. * * *chess960* defaults to the mode of the board. Pass ``True`` to force * Chess960 mode. */ uci(move: Move, { chess960 }?: { chess960?: boolean | null; }): string; /** * Parses the given move in UCI notation. * * Supports both Chess960 and standard UCI notation. * * The returned move is guaranteed to be either legal or a null move. * * :raises: * :exc:`ValueError` (specifically an exception specified below) if the move is invalid or illegal in the * current position (but not a null move). * * - :exc:`InvalidMoveError` if the UCI is syntactically invalid. * - :exc:`IllegalMoveError` if the UCI is illegal. */ parseUci(uci: string): Move; /** * Parses a move in UCI notation and puts it on the move stack. * * Returns the move. * * :raises: * :exc:`ValueError` (specifically an exception specified below) if the move is invalid or illegal in the * current position (but not a null move). * * - :exc:`InvalidMoveError` if the UCI is syntactically invalid. * - :exc:`IllegalMoveError` if the UCI is illegal. */ pushUci(uci: string): Move; xboard(move: Move, chess960?: boolean | null): string; parseXboard(xboard: string): Move; pushXboard: (san: string) => Move; /** * Checks if the given pseudo-legal move is an en passant capture. */ isEnPassant(move: Move): boolean; /** * Checks if the given pseudo-legal move is a capture. */ isCapture(move: Move): boolean; /** * Checks if the given pseudo-legal move is a capture or pawn move. */ isZeroing(move: Move): boolean; _reducesCastlingRights(move: Move): boolean; /** * Checks if the given pseudo-legal move is irreversible. * * In standard chess, pawn moves, captures, moves that destroy castling * rights and moves that cede en passant are irreversible. * * This method has false-negatives with forced lines. For example, a check * that will force the king to lose castling rights is not considered * irreversible. Only the actual king move is. */ isIrreversible(move: Move): boolean; /** * Checks if the given pseudo-legal move is a castling move. */ isCastling(move: Move): boolean; /** * Checks if the given pseudo-legal move is a kingside castling move. */ isKingsideCastling(move: Move): boolean; /** * Checks if the given pseudo-legal move is a queenside castling move. */ isQueensideCastling(move: Move): boolean; /** * Returns valid castling rights filtered from * :data:`~chess.Board.castlingRights`. */ cleanCastlingRights(): Bitboard; /** * Checks if the given side has castling rights. */ hasCastlingRights(color: Color): boolean; /** * Checks if the given side has kingside (that is h-side in Chess960) * castling rights. */ hasKingsideCastlingRights(color: Color): boolean; /** * Checks if the given side has queenside (that is a-side in Chess960) * castling rights. */ hasQueensideCastlingRights(color: Color): boolean; /** * Checks if there are castling rights that are only possible in Chess960. */ hasChess960CastlingRights(): boolean; /** * Gets a bitmask of possible problems with the position. * * :data:`~chess.STATUS_VALID` if all basic validity requirements are met. * This does not imply that the position is actually reachable with a * series of legal moves from the starting position. * * Otherwise, bitwise combinations of: * :data:`~chess.STATUS_NO_WHITE_KING`, * :data:`~chess.STATUS_NO_BLACK_KING`, * :data:`~chess.STATUS_TOO_MANY_KINGS`, * :data:`~chess.STATUS_TOO_MANY_WHITE_PAWNS`, * :data:`~chess.STATUS_TOO_MANY_BLACK_PAWNS`, * :data:`~chess.STATUS_PAWNS_ON_BACKRANK`, * :data:`~chess.STATUS_TOO_MANY_WHITE_PIECES`, * :data:`~chess.STATUS_TOO_MANY_BLACK_PIECES`, * :data:`~chess.STATUS_BAD_CASTLING_RIGHTS`, * :data:`~chess.STATUS_INVALID_EP_SQUARE`, * :data:`~chess.STATUS_OPPOSITE_CHECK`, * :data:`~chess.STATUS_EMPTY`, * :data:`~chess.STATUS_RACE_CHECK`, * :data:`~chess.STATUS_RACE_OVER`, * :data:`~chess.STATUS_RACE_MATERIAL`, * :data:`~chess.STATUS_TOO_MANY_CHECKERS`, * :data:`~chess.STATUS_IMPOSSIBLE_CHECK`. */ status(): Status; _validEpSquare(): Square | null; /** * Checks some basic validity requirements. * * See :func:`~chess.Board.status()` for details. */ isValid(): boolean; _epSkewered(king: Square, capturer: Square): boolean; _sliderBlockers(king: Square): Bitboard; _isSafe(king: Square, blockers: Bitboard, move: Move): boolean; _generateEvasions(king: Square, checkers: Bitboard, fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; generateLegalMoves(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; generateLegalEp(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; generateLegalCaptures(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; _attackedForKing(path: Bitboard, occupied: Bitboard): boolean; generateCastlingMoves(fromMask?: Bitboard, toMask?: Bitboard): IterableIterator; _fromChess960(chess960: boolean, fromSquare: Square, toSquare: Square, promotion?: PieceType | null, drop?: PieceType | null): Move; _toChess960(move: Move): Move; _transpositionKey(): bigint; toRepr(): string; _reprSvg(): string; equals(other: any): boolean; applyTransform(f: (board: Bitboard) => Bitboard): void; transform(f: (board: Bitboard) => Bitboard): this; applyMirror(): void; /** * Returns a mirrored copy of the board. * * The board is mirrored vertically and piece colors are swapped, so that * the position is equivalent modulo color. Also swap the "en passant" * square, castling rights and turn. * * Alternatively, :func:`~chess.Board.applyMirror()` can be used * to mirror the board. */ mirror(): this; /** * Creates a copy of the board. * * Defaults to copying the entire move stack. Alternatively, *stack* can * be ``False``, or an integer to copy a limited number of moves. */ copy({ stack }?: { stack?: boolean | number; }): this; /** * Creates a new empty board. Also see :func:`~chess.Board.clear()`. */ static empty(this: T, { chess960 }?: { chess960?: boolean; }): InstanceType; /** * Creates a new board from an EPD string. See * :func:`~chess.Board.setEpd()`. * * Returns the board and the dictionary of parsed operations as a tuple. */ static fromEpd(this: T, epd: string, { chess960 }?: { chess960?: boolean; }): [ InstanceType, Map> ]; static fromChess960Pos(this: T, scharnagl: number): InstanceType; } export declare class PseudoLegalMoveGenerator { board: Board; constructor(board: Board); bool(): boolean; count(): number; [Symbol.iterator](): IterableIterator; contains(move: Move): boolean; toString(): string; } export declare class LegalMoveGenerator { board: Board; constructor(board: Board); bool(): boolean; count(): number; [Symbol.iterator](): IterableIterator; contains(move: Move): boolean; toString(): string; } export type IntoSquareSet = Bitboard | Iterable; /** * A set of squares. * * >>> import chess * >>> * >>> squares = chess.SquareSet([chess.A8, chess.A1]) * >>> squares * SquareSet(0x0100_0000_0000_0001) * * >>> squares = chess.SquareSet(chess.BB_A8 | chess.BB_RANK_1) * >>> squares * SquareSet(0x0100_0000_0000_00ff) * * >>> print(squares) * 1 . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . * 1 1 1 1 1 1 1 1 * * >>> len(squares) * 9 * * >>> bool(squares) * True * * >>> chess.B1 in squares * True * * >>> for square in squares: * ... # 0 -- chess.A1 * ... # 1 -- chess.B1 * ... # 2 -- chess.C1 * ... # 3 -- chess.D1 * ... # 4 -- chess.E1 * ... # 5 -- chess.F1 * ... # 6 -- chess.G1 * ... # 7 -- chess.H1 * ... # 56 -- chess.A8 * ... print(square) * ... * 0 * 1 * 2 * 3 * 4 * 5 * 6 * 7 * 56 * * >>> list(squares) * [0, 1, 2, 3, 4, 5, 6, 7, 56] * * Square sets are internally represented by 64-bit integer masks of the * included squares. Bitwise operations can be used to compute unions, * intersections and shifts. * * >>> int(squares) * 72057594037928191 * * Also supports common set operations like * :func:`~chess.SquareSet.issubset()`, :func:`~chess.SquareSet.issuperset()`, * :func:`~chess.SquareSet.union()`, :func:`~chess.SquareSet.intersection()`, * :func:`~chess.SquareSet.difference()`, * :func:`~chess.SquareSet.symmetricDifference()` and * :func:`~chess.SquareSet.copy()` as well as * :func:`~chess.SquareSet.update()`, * :func:`~chess.SquareSet.intersectionUpdate()`, * :func:`~chess.SquareSet.differenceUpdate()`, * :func:`~chess.SquareSet.symmetricDifferenceUpdate()` and * :func:`~chess.SquareSet.clear()`. */ export declare class SquareSet { mask: Bitboard; constructor(squares?: IntoSquareSet); contains(square: Square): boolean; iter(): IterableIterator; reversed(): IterableIterator; length(): number; add(square: Square): void; discard(square: Square): void; /** * Tests if the square sets are disjoint. */ isdisjoint(other: IntoSquareSet): boolean; /** * Tests if this square set is a subset of another. */ issubset(other: IntoSquareSet): boolean; /** * Tests if this square set is a superset of another. */ issuperset(other: IntoSquareSet): boolean; union(other: IntoSquareSet): SquareSet; or(other: IntoSquareSet): SquareSet; intersection(other: IntoSquareSet): SquareSet; and(other: IntoSquareSet): SquareSet; difference(other: IntoSquareSet): SquareSet; sub(other: IntoSquareSet): SquareSet; symmetricDifference(other: IntoSquareSet): bigint; xor(other: IntoSquareSet): SquareSet; copy(): SquareSet; update(...others: IntoSquareSet[]): void; ior(other: IntoSquareSet): this; intersectionUpdate(...others: IntoSquareSet[]): void; iand(other: IntoSquareSet): this; differenceUpdate(other: IntoSquareSet): void; isub(other: IntoSquareSet): this; symmetricDifferenceUpdate(other: IntoSquareSet): void; ixor(other: IntoSquareSet): this; /** * Removes a square from the set. * * @thrwos :exc:`Error` if the given *square* was not in the set. */ remove(square: Square): void; /** * Removes and returns a square from the set. * * @throws :exc:`KeyError` if the set is empty. */ pop(): Square; /** * Removes all elements from this set. */ clear(): void; /** * Iterator over the subsets of this set. */ carryRippler(): IterableIterator; /** * Returns a vertically mirrored copy of this square set. */ mirror(): SquareSet; /** * Converts the set to a list of 64 bools. */ tolist(): any[]; bool(): boolean; equals(other: any): boolean; lshift(shift: bigint): SquareSet; rshift(shift: bigint): SquareSet; ilshift(shift: bigint): this; irshift(shift: bigint): this; invert(): SquareSet; int(): bigint; index(): bigint; toRepr(): string; toString(): string; _reprSvg_(): void; /** * All squares on the rank, file or diagonal with the two squares, if they * are aligned. * * >>> import chess * >>> * >>> print(chess.SquareSet.ray(chess.E2, chess.B5)) * . . . . . . . . * . . . . . . . . * 1 . . . . . . . * . 1 . . . . . . * . . 1 . . . . . * . . . 1 . . . . * . . . . 1 . . . * . . . . . 1 . . */ ray(a: Square, b: Square): SquareSet; /** * All squares on the rank, file or diagonal between the two squares * (bounds not included), if they are aligned. * * >>> import chess * >>> * >>> print(chess.SquareSet.between(chess.E2, chess.B5)) * . . . . . . . . * . . . . . . . . * . . . . . . . . * . . . . . . . . * . . 1 . . . . . * . . . 1 . . . . * . . . . . . . . * . . . . . . . . */ between(a: Square, b: Square): SquareSet; /** * Creates a :class:`~chess.SquareSet` from a single square. * * >>> import chess * >>> * >>> chess.SquareSet.fromSquare(chess.A1) == chess.BB_A1 * True */ static fromSquare(square: Square): SquareSet; } declare const _default: { COLORS: boolean[]; WHITE: boolean; BLACK: boolean; COLOR_NAMES: ColorName[]; PIECE_TYPES: PieceType[]; PAWN: PieceType; KNIGHT: PieceType; BISHOP: PieceType; ROOK: PieceType; QUEEN: PieceType; KING: PieceType; PIECE_SYMBOLS: (string | null)[]; PIECE_NAMES: (string | null)[]; pieceSymbol: (pieceType: PieceType) => string; pieceName: (pieceType: PieceType) => string; UNICODE_PIECE_SYMBOLS: { [key: string]: string; }; FILE_NAMES: string[]; RANK_NAMES: string[]; STARTING_FEN: string; STARTING_BOARD_FEN: string; STATUS_VALID: Status; STATUS_NO_WHITE_KING: Status; STATUS_NO_BLACK_KING: Status; STATUS_TOO_MANY_KINGS: Status; STATUS_TOO_MANY_WHITE_PAWNS: Status; STATUS_TOO_MANY_BLACK_PAWNS: Status; STATUS_PAWNS_ON_BACKRANK: Status; STATUS_TOO_MANY_WHITE_PIECES: Status; STATUS_TOO_MANY_BLACK_PIECES: Status; STATUS_BAD_CASTLING_RIGHTS: Status; STATUS_INVALID_EP_SQUARE: Status; STATUS_OPPOSITE_CHECK: Status; STATUS_EMPTY: Status; STATUS_RACE_CHECK: Status; STATUS_RACE_OVER: Status; STATUS_RACE_MATERIAL: Status; STATUS_TOO_MANY_CHECKERS: Status; STATUS_IMPOSSIBLE_CHECK: Status; Termination: typeof Termination; Outcome: typeof Outcome; InvalidMoveError: typeof InvalidMoveError; IllegalMoveError: typeof IllegalMoveError; AmbiguousMoveError: typeof AmbiguousMoveError; SQUARES: Square[]; A1: Square; B1: Square; C1: Square; D1: Square; E1: Square; F1: Square; G1: Square; H1: Square; A2: Square; B2: Square; C2: Square; D2: Square; E2: Square; F2: Square; G2: Square; H2: Square; A3: Square; B3: Square; C3: Square; D3: Square; E3: Square; F3: Square; G3: Square; H3: Square; A4: Square; B4: Square; C4: Square; D4: Square; E4: Square; F4: Square; G4: Square; H4: Square; A5: Square; B5: Square; C5: Square; D5: Square; E5: Square; F5: Square; G5: Square; H5: Square; A6: Square; B6: Square; C6: Square; D6: Square; E6: Square; F6: Square; G6: Square; H6: Square; A7: Square; B7: Square; C7: Square; D7: Square; E7: Square; F7: Square; G7: Square; H7: Square; A8: Square; B8: Square; C8: Square; D8: Square; E8: Square; F8: Square; G8: Square; H8: Square; SQUARE_NAMES: string[]; parseSquare: (name: string) => Square; squareName: (square: Square) => string; square: (fileIndex: RankOrFileIndex, rankIndex: RankOrFileIndex) => Square; squareFile: (square: Square) => RankOrFileIndex; squareRank: (square: Square) => RankOrFileIndex; squareDistance: (a: Square, b: Square) => number; squareManhattanDistance: (a: Square, b: Square) => number; squareKnightDistance: (a: Square, b: Square) => number; squareMirror: (square: Square) => Square; SQUARES_180: Square[]; BB_EMPTY: bigint; BB_ALL: bigint; BB_SQUARES: bigint[]; BB_A1: bigint; BB_B1: bigint; BB_C1: bigint; BB_D1: bigint; BB_E1: bigint; BB_F1: bigint; BB_G1: bigint; BB_H1: bigint; BB_A2: bigint; BB_B2: bigint; BB_C2: bigint; BB_D2: bigint; BB_E2: bigint; BB_F2: bigint; BB_G2: bigint; BB_H2: bigint; BB_A3: bigint; BB_B3: bigint; BB_C3: bigint; BB_D3: bigint; BB_E3: bigint; BB_F3: bigint; BB_G3: bigint; BB_H3: bigint; BB_A4: bigint; BB_B4: bigint; BB_C4: bigint; BB_D4: bigint; BB_E4: bigint; BB_F4: bigint; BB_G4: bigint; BB_H4: bigint; BB_A5: bigint; BB_B5: bigint; BB_C5: bigint; BB_D5: bigint; BB_E5: bigint; BB_F5: bigint; BB_G5: bigint; BB_H5: bigint; BB_A6: bigint; BB_B6: bigint; BB_C6: bigint; BB_D6: bigint; BB_E6: bigint; BB_F6: bigint; BB_G6: bigint; BB_H6: bigint; BB_A7: bigint; BB_B7: bigint; BB_C7: bigint; BB_D7: bigint; BB_E7: bigint; BB_F7: bigint; BB_G7: bigint; BB_H7: bigint; BB_A8: bigint; BB_B8: bigint; BB_C8: bigint; BB_D8: bigint; BB_E8: bigint; BB_F8: bigint; BB_G8: bigint; BB_H8: bigint; BB_CORNERS: bigint; BB_CENTER: bigint; BB_LIGHT_SQUARES: bigint; BB_DARK_SQUARES: bigint; BB_FILES: bigint[]; BB_FILE_A: bigint; BB_FILE_B: bigint; BB_FILE_C: bigint; BB_FILE_D: bigint; BB_FILE_E: bigint; BB_FILE_F: bigint; BB_FILE_G: bigint; BB_FILE_H: bigint; BB_RANKS: bigint[]; BB_RANK_1: bigint; BB_RANK_2: bigint; BB_RANK_3: bigint; BB_RANK_4: bigint; BB_RANK_5: bigint; BB_RANK_6: bigint; BB_RANK_7: bigint; BB_RANK_8: bigint; BB_BACKRANKS: bigint; lsb: (bb: bigint) => Square; scanForward: typeof scanForward; msb: (bb: bigint) => Square; scanReversed: typeof scanReversed; popcount: (bb: bigint) => number; flipVertical: (bb: bigint) => bigint; flipHorizontal: (bb: bigint) => bigint; flipDiagonal: (bb: bigint) => bigint; flipAntiDiagonal: (bb: bigint) => bigint; shiftDown: (b: bigint) => bigint; shift2Down: (b: bigint) => bigint; shiftUp: (b: bigint) => bigint; shift2Up: (b: bigint) => bigint; shiftRight: (b: bigint) => bigint; shift2Right: (b: bigint) => bigint; shiftLeft: (b: bigint) => bigint; shift2Left: (b: bigint) => bigint; shiftUpLeft: (b: bigint) => bigint; shiftUpRight: (b: bigint) => bigint; shiftDownLeft: (b: bigint) => bigint; shiftDownRight: (b: bigint) => bigint; _slidingAttacks: (square: Square, occupied: bigint, deltas: number[]) => bigint; _stepAttacks: (square: Square, deltas: number[]) => bigint; BB_KNIGHT_ATTACKS: bigint[]; BB_KING_ATTACKS: bigint[]; BB_PAWN_ATTACKS: bigint[][]; _edges: (square: Square) => bigint; _carryRippler: typeof _carryRippler; _attackTable: (deltas: number[]) => [bigint[], Map[]]; BB_DIAG_MASKS: bigint[]; BB_DIAG_ATTACKS: Map[]; BB_FILE_MASKS: bigint[]; BB_FILE_ATTACKS: Map[]; BB_RANK_MASKS: bigint[]; BB_RANK_ATTACKS: Map[]; _rays: () => bigint[][]; BB_RAYS: bigint[][]; ray: (a: Square, b: Square) => bigint; between: (a: Square, b: Square) => bigint; SAN_REGEX: RegExp; FEN_CASTLING_REGEX: RegExp; Piece: typeof Piece; Move: typeof Move; BaseBoard: typeof BaseBoard; _BoardState: typeof _BoardState; Board: typeof Board; PseudoLegalMoveGenerator: typeof PseudoLegalMoveGenerator; LegalMoveGenerator: typeof LegalMoveGenerator; SquareSet: typeof SquareSet; }; export default _default; //# sourceMappingURL=index.d.ts.map