Internal API Reference

ChessEngine.TTEntryType

Transposition 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
source
ChessEngine.compute_eval_and_phaseMethod
compute_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.

source
ChessEngine.find_magicMethod

Try 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
source
ChessEngine.flip_tableMethod

Flip 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.

source
ChessEngine.game_phaseMethod

Compute game phase (0 = endgame, 1 = opening). A simple heuristic: count non-pawn, non-king material.

source
ChessEngine.generate_magicsMethod

Compute magic numbers for all squares.

  • masks: precomputed mask table (bishop or rook)
  • attack_fn: function (sq, occ) → attacks
source
ChessEngine.generate_sliding_moves_magicMethod

Generate 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
source
ChessEngine.king_squareMethod

Get the square index of the king for the given side

  • board: Board struct
  • side: Side (WHITE or BLACK)

Returns: Int (square index 0..63)

source
ChessEngine.move_ordering_scoreMethod

Heuristic to score moves for ordering:

  • Promotions are prioritized highest.
  • Captures are prioritized higher.
  • Moves giving check are prioritized.
  • Quiet moves get a lower score.
source
ChessEngine.piece_from_symbolMethod
piece_from_symbol(c::AbstractChar, side::Symbol)

Return the piece constant corresponding to promotion symbol c and the moving side (:white or :black).

source
ChessEngine.piece_square_valueMethod

Return 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
source
ChessEngine.square_attackedMethod

Check if a square is attacked by the given side.

  • board: Board struct
  • sq: Int (square index 0..63)
  • attacker: Side (WHITE or BLACK)

Returns: Bool

source
ChessEngine.store_killer!Method

Store a killer move for the given ply. Only quiet moves (non-captures) are stored.

  • m: the move to store
  • ply: the current ply
source
ChessEngine.tt_probeMethod

Look 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.

source