diff --git a/progress_tracking/collect_benchmarks.py b/progress_tracking/collect_benchmarks.py index d88d129..020588e 100644 --- a/progress_tracking/collect_benchmarks.py +++ b/progress_tracking/collect_benchmarks.py @@ -9,9 +9,9 @@ from openpyxl.utils import get_column_letter # --- Configuration --- # Adjust these paths if your benchmark names are different! -PERFT_JSON_PATH = "C:/Users/Moritz/RustroverProjects/ChessEngine/target/criterion/standard_perft5/new/estimates.json" -EVAL_JSON_PATH = "C:/Users/Moritz/RustroverProjects/ChessEngine/target/criterion/standard_board_evaluation/new/estimates.json" -EXCEL_FILE = "C:/Users/Moritz/RustroverProjects/ChessEngine/progress_tracking/progress.xlsx" +PERFT_JSON_PATH = "target/criterion/standard_perft5/new/estimates.json" +EVAL_JSON_PATH = "target/criterion/standard_board_evaluation/new/estimates.json" +EXCEL_FILE = "progress_tracking/progress.xlsx" HEADERS = ["TIMESTAMP", "COMMIT", "MESSAGE", "PERFT (ms)", "EVAL (ps)", "SUITE (%)"] COLUMN_WIDTHS = { @@ -213,4 +213,4 @@ def main(): print(f" SUITE: {suite_score:.2f} %") if __name__ == "__main__": - main() \ No newline at end of file + main() diff --git a/progress_tracking/progress.xlsx b/progress_tracking/progress.xlsx index abfbf9b..9cc82c6 100644 Binary files a/progress_tracking/progress.xlsx and b/progress_tracking/progress.xlsx differ diff --git a/src/bin/suite.rs b/src/bin/suite.rs index 75cfa24..cd7e569 100644 --- a/src/bin/suite.rs +++ b/src/bin/suite.rs @@ -25,7 +25,7 @@ fn load_csv(path: &str) -> io::Result>> { fn main() { let mut total_tests: f32 = 0.0; let mut correct_tests: f32 = 0.0; - let sts = load_csv("C:/Users/Moritz/RustroverProjects/ChessEngine/src/bin/stockfish_testsuite.csv").unwrap(); + let sts = load_csv("src/bin/stockfish_testsuite.csv").unwrap(); let mut engine = Engine::new("Yakari".to_string(), "EiSiMo".to_string()); // Set the time limit to 1 second @@ -61,4 +61,4 @@ fn main() { } println!("{}", correct_tests / (total_tests / 100.0)); -} \ No newline at end of file +} diff --git a/src/movegen/legal_check.rs b/src/movegen/legal_check.rs index 0c276a2..bf32dbf 100644 --- a/src/movegen/legal_check.rs +++ b/src/movegen/legal_check.rs @@ -1,8 +1,12 @@ -// FILENAME: legal_check.rs use crate::board::{Board, Color, PieceType}; use crate::movegen::tables::{get_bishop_attacks, get_rook_attacks, ATTACKING_PAWNS, KING_ATTACKS, KNIGHT_ATTACKS, MAGICS_BISHOP, MAGICS_ROOK, PREMASKS_BISHOP, PREMASKS_ROOK, RELEVANT_BITS_BISHOP, RELEVANT_BITS_ROOK}; use crate::square::{Square, SQUARES}; +pub fn is_current_king_attacked(board: &Board) -> bool { + let king = board.pieces[PieceType::King as usize][board.side_to_move as usize]; + is_square_attacked(board, SQUARES[king.trailing_zeros() as usize], board.side_to_move) +} + /// Checks if the king of the side that is NOT to move is in check pub fn is_other_king_attacked(board: &Board) -> bool { let king = board.pieces[PieceType::King as usize][!board.side_to_move as usize]; diff --git a/src/search/alpha_beta.rs b/src/search/alpha_beta.rs index a284833..ea9e69a 100644 --- a/src/search/alpha_beta.rs +++ b/src/search/alpha_beta.rs @@ -1,7 +1,7 @@ use crate::board::{Board, Color}; // <-- Assuming you have a Color enum (e.g., Color::White, Color::Black) use crate::eval::basic::evaluate_board; use crate::movegen::generate_pseudo_legal_moves; -use crate::movegen::legal_check::is_other_king_attacked; +use crate::movegen::legal_check::*; use crate::r#move::{Move, MoveList}; // A score high enough to be > any material eval, but low enough to not overflow when adding ply @@ -63,10 +63,7 @@ pub fn alpha_beta( } if !legal_moves_found { - if is_other_king_attacked(board) { - // Checkmate - // The score is *less* negative the *longer* it takes to be mated (higher ply) - // This translates to a *higher* score for the winner for a *faster* mate + if is_current_king_attacked(board) { return (None, -MATE_SCORE + (ply as i32)); } else { // Stalemate @@ -75,4 +72,4 @@ pub fn alpha_beta( } (best_move, best_score) -} \ No newline at end of file +}