bitstackchess 0.1.1

A bitboard‐based chess game engine with 10 × u128 move history
Documentation
//! Public trait that any chess‐engine (or variant) should implement.

use crate::core::Move10;
use crate::board::PieceMapping;
use crate::board::Occupied;
use crate::board::CapturedBits;
use crate::rules::checkmate::{Color, GameResult};

/// Errors that can occur when pushing a move.
#[derive(Debug)]
pub enum MoveError {
    IllegalMove,
    OutOfBounds,
    NotYourTurn,
    KingInCheckAfterMove,
    // etc.
}

/// The minimal interface a chess engine must provide.
pub trait ChessEngine {
    /// Get the current PieceMapping (which piece sits on which square).
    fn current_mapping(&self) -> &PieceMapping;

    /// Get the current occupancy bitboard.
    fn current_occupied(&self) -> Occupied;

    /// Get the current captured‐bits mask.
    fn current_captured_bits(&self) -> CapturedBits;

    /// Return side to move: White or Black.
    fn side_to_move(&self) -> Color;

    /// Return the current en_passant_target if any.
    fn en_passant_target(&self) -> Option<u8>;

    /// Return the number of plies played so far (0..=128).
    fn ply(&self) -> usize;

    /// Return GameResult (Checkmate/Stalemate/Ongoing).
    fn game_result(&self) -> GameResult;

    /// Return the Move10 code stored at ply index i (0..ply−1).
    fn read_ply(&self, i: usize) -> Move10;

    /// Generate all pseudo‐legal moves (Move10) for side_to_move, ignoring self‐check.
    fn generate_pseudo_legal_moves(&self) -> Vec<Move10>;

    /// Push a move onto the stack.
    /// Returns Ok(()) if move is legal and does not leave king in check.
    /// Otherwise returns Err(MoveError).
    fn push_move(&mut self, mv: Move10) -> Result<(), MoveError>;

    /// Pop (undo) the last half‐move, if any.
    fn pop_move(&mut self);

    /// Reset to the starting position (also clears all bit‐planes).
    fn reset(&mut self);
}