Internal API Reference
OrbisChessEngine.TTEntry — Type
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
Base.show — Method
Base.show(io::IO, board::Board)Display a simple ASCII representation of the given 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 positionBase.show — Method
Base.show(io::IO, game::Game)Display a simple ASCII representation of the given 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
g = Game() # prints the initial chess positionOrbisChessEngine._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.
OrbisChessEngine.clearbit — Method
Clear bit at square sq.
OrbisChessEngine.compute_eval_and_phase — Method
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.
OrbisChessEngine.count_bits — Method
Count the number of bits set in a UInt64.
OrbisChessEngine.extract_root_pv — Method
Reconstruct the principal variation (PV) from the transposition table
OrbisChessEngine.file_rank — Method
file_rank(sq) -> (Int, Int)Return file (1..8) and rank (1..8) for a square index
OrbisChessEngine.find_magic — Method
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
OrbisChessEngine.flip_table — Method
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.
OrbisChessEngine.generate_magics — Method
Compute magic numbers for all squares.
- masks: precomputed mask table (bishop or rook)
- attack_fn: function (sq, occ) → attacks
OrbisChessEngine.generate_pawn_moves! — Method
Generate pseudo-legal pawn moves in-place
board: Board structmoves: preallocated buffer to append moves
Returns: number of moves added
OrbisChessEngine.generate_pawn_moves — Method
Generate pseudo-legal pawn moves for the side to move
board: Board struct
Returns: Vector of Move
OrbisChessEngine.is_fifty_move_rule — Method
Check for fifty-move rule
board: Board struct
Returns: Bool
OrbisChessEngine.is_insufficient_material — Method
is_insufficient_material(board::Board) -> BoolCheck for insufficient material to mate
board: Board struct
OrbisChessEngine.is_threefold_repetition — Method
Check for threefold repetition
board: Board struct
Returns: Bool
OrbisChessEngine.king_square — Method
king_square(board::Board, side::Side) -> IntGet the square index of the king for the given side
board: Board structside: Side (WHITE or BLACK)
Returns: Int (square index 0..63)
OrbisChessEngine.make_null_move! — Method
Apply a null move (pass) to the board, modifying it in place. Used for null-move pruning.
OrbisChessEngine.move_ordering_score — Method
move_ordering_score(board::Board, m::Move, ply::Int)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.
OrbisChessEngine.next_square — Method
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.
OrbisChessEngine.occupancy — Method
occupancy(board::Board) -> UInt64Returns a bitboard of all occupied squares.
OrbisChessEngine.occupancy_variations — Method
Generate all possible occupancy bitboards for the given mask
OrbisChessEngine.piece_at — Method
piece_at(board::Board, sq) -> IntReturn the piece type at a given square (0..63) using bitboards.
OrbisChessEngine.piece_from_symbol — Method
piece_from_symbol(c::AbstractChar, side::Symbol)Return the piece constant corresponding to promotion symbol c and the moving side (:white or :black).
OrbisChessEngine.piece_square_value — Method
Return the PSQT value of a piece on a given square.
- piece: Piece.WPAWN..Piece.BKING
- square: 0..63 (a1=0, h8=63)
- phase: Int (0..MAX_PHASE)
OrbisChessEngine.ray_between — Method
ray_between(board, king_sq::Int, from_sq::Int) -> BoolReturns true if moving a piece from from_sq could open a sliding attack (rook, bishop, queen) towards the king at king_sq.
OrbisChessEngine.setbit — Method
Set bit at square sq.
OrbisChessEngine.sliding_attack_from_occupancy — Method
Generic sliding attack generator.
- sq: square index
- occ: occupancy bitboard
- directions: list of (df, dr) directions
OrbisChessEngine.sliding_mask — Method
Generic sliding mask generator.
- sq: square index (0..63)
- directions: list of (df, dr) directions
OrbisChessEngine.square_attacked — Method
square_attacked(board, sq, attacker) -> BoolCheck if a square is attacked by the given side.
board: Board structsq: Int (square index 0..63)attacker: Side (WHITE or BLACK)
Returns: Bool
OrbisChessEngine.square_index — Method
Map algebraic notation (e.g. 'e3') → square index (0..63).
OrbisChessEngine.square_index — Method
Map (file, rank) → square index (0..63). file=1→a, rank=1→1.
OrbisChessEngine.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
OrbisChessEngine.testbit — Method
Check if bit at square sq is set.
OrbisChessEngine.tt_index — Method
Get index in transposition table from hash.
OrbisChessEngine.tt_probe — Method
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.
OrbisChessEngine.tt_store — Method
Store an entry in the transposition table.
OrbisChessEngine.undo_null_move! — Method
Undo a null move, restoring the previous board state.