Internal API Reference
ChessEngine.TTEntry
— TypeTransposition table entry.
- key: Zobrist hash of the position (for collision checking)
- value: evaluation score
- depth: search depth at which this value was computed
- node_type: type of node (EXACT, LOWERBOUND, UPPERBOUND)
- best_move: best move found from this position
ChessEngine.clearbit
— MethodClear bit at square sq.
ChessEngine.compute_eval_and_phase
— Methodcompute_eval_and_phase(board::Board) -> (Int, Int)
Compute the evaluation score (from White's perspective) and the game phase value from scratch for a given board.
ChessEngine.count_bits
— MethodCount the number of bits set in a UInt64.
ChessEngine.extract_pv
— MethodReconstruct the principal variation (PV) from the transposition table
ChessEngine.file_rank
— MethodReturn file (1..8) and rank (1..8) for a square index
ChessEngine.find_magic
— MethodTry to find a magic number for a given square.
- sq: square index 0–63
- masks: precomputed mask table (bishop or rook)
- attack_fn: function (sq, occ) → attacks
- tries: number of random candidates to attempt
ChessEngine.flip_table
— MethodFlip a piece-square table vertically (white → black perspective). Input is a 64-element vector (row-major, starting at A8). Returns a new 64-element vector with ranks mirrored.
ChessEngine.game_phase
— MethodCompute game phase (0 = endgame, 1 = opening). A simple heuristic: count non-pawn, non-king material.
ChessEngine.generate_bishop_moves
— MethodGenerate pseudo-legal bishop moves for the given side
board
: Board struct
Returns: Vector of Move
ChessEngine.generate_magics
— MethodCompute magic numbers for all squares.
- masks: precomputed mask table (bishop or rook)
- attack_fn: function (sq, occ) → attacks
ChessEngine.generate_pawn_moves!
— MethodGenerate pseudo-legal pawn moves in-place
board
: Board structmoves
: preallocated buffer to append moves
Returns: number of moves added
ChessEngine.generate_pawn_moves
— MethodGenerate pseudo-legal pawn moves for the side to move
board
: Board struct
Returns: Vector of Move
ChessEngine.generate_queen_moves
— MethodGenerate pseudo-legal queen moves for the given side
board
: Board struct
Returns: Vector of Move
ChessEngine.generate_rook_moves
— MethodGenerate pseudo-legal rook moves for the given side
board
: Board struct
Returns: Vector of Move
ChessEngine.generate_sliding_moves_magic
— MethodGenerate pseudo-legal moves for a sliding piece using magic bitboards.
- bb_piece: bitboard of the moving piece
- masktable, attacktable, magic_table: precomputed tables
- friendlypieces, enemypieces: arrays of piece indices
ChessEngine.is_fifty_move_rule
— MethodCheck for fifty-move rule
board
: Board struct
Returns: Bool
ChessEngine.is_insufficient_material
— MethodCheck for insufficient material to mate
board
: Board struct
Returns: Bool
ChessEngine.is_threefold_repetition
— MethodCheck for threefold repetition
board
: Board struct
Returns: Bool
ChessEngine.king_square
— MethodGet the square index of the king for the given side
board
: Board structside
: Side (WHITE or BLACK)
Returns: Int (square index 0..63)
ChessEngine.make_null_move!
— MethodApply a null move (pass) to the board, modifying it in place. Used for null-move pruning.
ChessEngine.move_ordering_score
— MethodHeuristic to score moves for ordering:
- Promotions are prioritized highest.
- Captures are prioritized higher.
- Moves giving check are prioritized.
- Quiet moves get a lower score.
ChessEngine.occupancy_variations
— MethodGenerate all possible occupancy bitboards for the given mask
ChessEngine.on_board
— MethodCheck if a square index is on the board
ChessEngine.piece_at
— MethodReturn the piece type at a given square (0..63) using bitboards.
ChessEngine.piece_from_symbol
— Methodpiece_from_symbol(c::AbstractChar, side::Symbol)
Return the piece constant corresponding to promotion symbol c
and the moving side (:white
or :black
).
ChessEngine.piece_square_value
— MethodReturn the PSQT value of a piece on a given square.
- piece: Piece.WPAWN..Piece.BKING
- square: 0..63 (a1=0, h8=63)
- phase: Float64 in [0.0, 1.0], where 1.0 = opening, 0.0 = endgame
ChessEngine.setbit
— MethodSet bit at square sq.
ChessEngine.sliding_attack_from_occupancy
— MethodGeneric sliding attack generator.
- sq: square index
- occ: occupancy bitboard
- directions: list of (df, dr) directions
ChessEngine.sliding_mask
— MethodGeneric sliding mask generator.
- sq: square index (0..63)
- directions: list of (df, dr) directions
ChessEngine.square_attacked
— MethodCheck if a square is attacked by the given side.
board
: Board structsq
: Int (square index 0..63)attacker
: Side (WHITE or BLACK)
Returns: Bool
ChessEngine.square_index
— MethodMap algebraic notation (e.g. 'e3') → square index (0..63).
ChessEngine.square_index
— MethodMap (file, rank) → square index (0..63). file=1→a, rank=1→1.
ChessEngine.store_killer!
— MethodStore a killer move for the given ply. Only quiet moves (non-captures) are stored.
- m: the move to store
- ply: the current ply
ChessEngine.testbit
— MethodCheck if bit at square sq is set.
ChessEngine.tt_index
— MethodGet index in transposition table from hash.
ChessEngine.tt_probe
— MethodLook up a position in the transposition table.
- hash: Zobrist hash of the position
- depth: current search depth
- α: alpha value
- β: beta value
Returns a tuple (value, best_move, hit) where hit is true if a valid entry was found.
ChessEngine.tt_store
— MethodStore an entry in the transposition table.
ChessEngine.unmake_null_move!
— MethodUndo a null move, restoring the previous board state.