Internal API Reference

OrbisChessEngine.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
Base.showMethod
Base.show(io::IO, x::Union{Board,Game})

Display a simple ASCII representation of the given Board (or a Game's board) in the terminal.

Each square shows either a piece or a dot . for empty squares. Piece symbols:

  • White: P (pawn), N (knight), B (bishop), R (rook), Q (queen), K (king)
  • Black: p (pawn), n (knight), b (bishop), r (rook), q (queen), k (king)

The board is printed with rank 8 at the top and file a on the left.

Example

b = Board() # prints the initial chess position
source
OrbisChessEngine._filter_legal_moves!Method
_filter_legal_moves!(board, pseudo, start, stop, moves, n_moves)

Filters pseudo-legal moves into legal moves, avoiding full make/undo for moves that clearly cannot expose the king.

source
OrbisChessEngine.attackers_toMethod
attackers_to(board::Board, sq::Int, occ::UInt64) -> UInt64

Bitboard of every piece (either color) that attacks sq, given a custom occupancy occ – not necessarily board's actual occupancy. Used by see to simulate a shrinking board as pieces are captured off in an exchange, without ever touching board itself. Pawn/knight/king attacks are read straight from board.bitboards (their attack masks don't depend on occupancy) and filtered against occ at the end; sliding attacks already respect occ via sliding_attack_from_occupancy.

source
OrbisChessEngine.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
OrbisChessEngine.find_uci_moveMethod
find_uci_move(board::Board, uci_str::AbstractString) -> Move

Resolve a UCI move string (e.g. "e2e4", "e7e8q", "e1g1" for castling) to the matching legal Move on board. Throws an ErrorException if no legal move matches.

source
OrbisChessEngine.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
OrbisChessEngine.gives_checkMethod
gives_check(board::Board, m::Move) -> Bool

Cheap static test for whether making m gives check, without the cost of a full make_move!/undo_move! round trip: computes the post-move occupancy and the moved (or promoted-to) piece's attack pattern from m.to, and tests whether it covers the enemy king's square.

Only detects direct checks from the moved/promoted piece itself – not discovered checks, nor a check delivered by the rook on a castling move.

source
OrbisChessEngine.king_ray_squaresMethod
king_ray_squares(occ, king_sq) -> UInt64

Bitboard of every square a piece could move from and possibly open a sliding discovered check on king_sq: for each of the 8 rook/bishop directions from king_sq, every square out to and including the first occupied square in that direction.

Computed once per node.

source
OrbisChessEngine.king_squareMethod
king_square(board::Board, side::Side) -> Int

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
OrbisChessEngine.mobility_and_king_safetyMethod
mobility_and_king_safety(board::Board) -> Int

Mobility and king-safety term for evaluate, from White's point of view. Each minor/major piece's attack bitboard is computed once and used both for its own side's mobility score and (if it reaches into the enemy king's zone) the enemy king's attacker weight.

source
OrbisChessEngine.move_ordering_scoreMethod
move_ordering_score(board::Board, m::Move, ply::Int)

Heuristic to score moves for ordering:

  • Promotions are prioritized highest.
  • Captures are prioritized higher, ordered by true exchange value (SEE).
  • Moves giving check are prioritized.
  • Killer moves (quiet moves that caused a cutoff at this ply before) next.
  • Other quiet moves are ordered by the history heuristic.
source
OrbisChessEngine.next_squareMethod
next_square(sq::Int, dir::Tuple{Int,Int}) -> Union{Int,Nothing}

Returns the next square index in direction dir = (df, dr) from sq. Returns nothing if it goes off-board.

source
OrbisChessEngine.seeMethod
see(board::Board, m::Move) -> Int

Static Exchange Evaluation for capture move m: play out the full capture sequence on m.to (each side recaptures with its least valuable attacker, alternating, only continuing if doing so doesn't lose material) using bitboards only – no make_move!/undo_move!. Returns the net material result in centipawns for the side making m (positive = m wins material). m is assumed to be an actual capture (m.capture != 0 or m.en_passant).

Simplifications:

  • A promoting capture's attacker is valued at the pawn's own value, not the promoted piece.
  • Pins are ignored.
source
OrbisChessEngine.square_attackedMethod
square_attacked(board, sq, attacker) -> Bool

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
OrbisChessEngine.to_uciMethod
to_uci(m::Move) -> String

Format a Move in UCI long algebraic notation, e.g. "e2e4", "e7e8q". Unlike string(m) (used for human-readable display), this never uses "O-O" or "=", since UCI represents castling as the king's from/to squares and promotions with a bare lowercase letter.

source
OrbisChessEngine.tt_probeFunction

Look up a position in the transposition table.

  • hash: Zobrist hash of the position
  • depth: current search depth
  • α: alpha value
  • β: beta value
  • ply: current node's distance from this search's root

Returns a tuple (value, best_move, hit) where hit is true if a valid entry was found.

source
OrbisChessEngine.uci_info_lineMethod

Print a UCI "info" line for the given depth's result: score (relative to the side to move, per the UCI spec), elapsed time, node count/rate, and PV in UCI notation.

source
OrbisChessEngine.update_history!Method

Update the history heuristic for a quiet move that caused a beta cutoff. Only quiet (non-capture) moves are tracked; captures already order via SEE. Score is bumped by depth^2 (moves that caused cutoffs deeper in the tree are weighted more heavily), clamped at HISTORY_MAX.

  • side: the side that made the move
  • m: the move to reward
  • depth: remaining search depth at the node where the cutoff occurred
source