fix checkmate search
This commit is contained in:
parent
6b280c35bb
commit
4a8e1ce52c
5 changed files with 14 additions and 13 deletions
|
|
@ -9,9 +9,9 @@ from openpyxl.utils import get_column_letter
|
||||||
|
|
||||||
# --- Configuration ---
|
# --- Configuration ---
|
||||||
# Adjust these paths if your benchmark names are different!
|
# Adjust these paths if your benchmark names are different!
|
||||||
PERFT_JSON_PATH = "C:/Users/Moritz/RustroverProjects/ChessEngine/target/criterion/standard_perft5/new/estimates.json"
|
PERFT_JSON_PATH = "target/criterion/standard_perft5/new/estimates.json"
|
||||||
EVAL_JSON_PATH = "C:/Users/Moritz/RustroverProjects/ChessEngine/target/criterion/standard_board_evaluation/new/estimates.json"
|
EVAL_JSON_PATH = "target/criterion/standard_board_evaluation/new/estimates.json"
|
||||||
EXCEL_FILE = "C:/Users/Moritz/RustroverProjects/ChessEngine/progress_tracking/progress.xlsx"
|
EXCEL_FILE = "progress_tracking/progress.xlsx"
|
||||||
HEADERS = ["TIMESTAMP", "COMMIT", "MESSAGE", "PERFT (ms)", "EVAL (ps)", "SUITE (%)"]
|
HEADERS = ["TIMESTAMP", "COMMIT", "MESSAGE", "PERFT (ms)", "EVAL (ps)", "SUITE (%)"]
|
||||||
|
|
||||||
COLUMN_WIDTHS = {
|
COLUMN_WIDTHS = {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -25,7 +25,7 @@ fn load_csv(path: &str) -> io::Result<Vec<Vec<String>>> {
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut total_tests: f32 = 0.0;
|
let mut total_tests: f32 = 0.0;
|
||||||
let mut correct_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());
|
let mut engine = Engine::new("Yakari".to_string(), "EiSiMo".to_string());
|
||||||
|
|
||||||
// Set the time limit to 1 second
|
// Set the time limit to 1 second
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
// FILENAME: legal_check.rs
|
|
||||||
use crate::board::{Board, Color, PieceType};
|
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::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};
|
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
|
/// Checks if the king of the side that is NOT to move is in check
|
||||||
pub fn is_other_king_attacked(board: &Board) -> bool {
|
pub fn is_other_king_attacked(board: &Board) -> bool {
|
||||||
let king = board.pieces[PieceType::King as usize][!board.side_to_move as usize];
|
let king = board.pieces[PieceType::King as usize][!board.side_to_move as usize];
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::board::{Board, Color}; // <-- Assuming you have a Color enum (e.g., Color::White, Color::Black)
|
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::eval::basic::evaluate_board;
|
||||||
use crate::movegen::generate_pseudo_legal_moves;
|
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};
|
use crate::r#move::{Move, MoveList};
|
||||||
|
|
||||||
// A score high enough to be > any material eval, but low enough to not overflow when adding ply
|
// 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 !legal_moves_found {
|
||||||
if is_other_king_attacked(board) {
|
if is_current_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
|
|
||||||
return (None, -MATE_SCORE + (ply as i32));
|
return (None, -MATE_SCORE + (ply as i32));
|
||||||
} else {
|
} else {
|
||||||
// Stalemate
|
// Stalemate
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue