fix checkmate search

This commit is contained in:
Moritz Eigenauer 2025-11-17 10:52:15 +01:00
parent 6b280c35bb
commit 4a8e1ce52c
5 changed files with 14 additions and 13 deletions

View file

@ -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 = {

Binary file not shown.

View file

@ -25,7 +25,7 @@ fn load_csv(path: &str) -> io::Result<Vec<Vec<String>>> {
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

View file

@ -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];

View file

@ -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