timecat 1.52.0

A NNUE-based chess engine that implements the Negamax algorithm and can be integrated into any project as a library. It features move generation, advanced position evaluation through NNUE, and move searching capabilities.
Documentation
use super::*;

// TODO: Is is possible to change Vec<Move> to impl Iterator<Item = Move>?
pub fn extract_pv_from_t_table(
    position: &ChessPosition,
    transposition_table: &TranspositionTable,
) -> Vec<Move> {
    let mut pv = Vec::new();
    let best_move = transposition_table.read_best_move(position.get_hash());
    if let Some(best_move) = best_move {
        pv.push(best_move);
        pv.append(&mut extract_pv_from_t_table(
            &position.make_move_new(best_move),
            transposition_table,
        ));
    }
    pv
}

pub fn get_pv_as_uci(pv: &[Move]) -> String {
    let mut pv_string = String::new();
    for move_ in pv {
        write_unchecked!(pv_string, "{} ", move_.uci());
    }
    pv_string.pop(); // Remove trailing space
    pv_string
}

pub fn get_pv_as_algebraic(position: &ChessPosition, pv: &[Move], long: bool) -> String {
    let mut position = position.clone();
    let mut pv_string = String::new();
    for move_ in pv {
        pv_string += &if position.is_legal(move_) {
            let (san, new_position) = move_.algebraic_and_new_position(&position, long).unwrap();
            position = new_position;
            san
        } else {
            move_.uci().colorize(ERROR_MESSAGE_STYLE).into()
        };
        pv_string.push(' ');
    }
    pv_string.pop(); // Remove trailing space
    pv_string
}

#[inline]
pub fn get_pv_as_san(position: &ChessPosition, pv: &[Move]) -> String {
    get_pv_as_algebraic(position, pv, false)
}

#[inline]
pub fn get_pv_as_lan(position: &ChessPosition, pv: &[Move]) -> String {
    get_pv_as_algebraic(position, pv, true)
}

#[inline]
pub fn get_pv_string(position: &ChessPosition, pv: &[Move]) -> String {
    if GLOBAL_TIMECAT_STATE.is_in_console_mode() {
        get_pv_as_algebraic(
            position,
            pv,
            GLOBAL_TIMECAT_STATE.use_long_algebraic_notation(),
        )
    } else {
        get_pv_as_uci(pv)
    }
}