From 9ea86e62ef0d32f03845231e90b1b968aa48a14a Mon Sep 17 00:00:00 2001 From: Arseniy Surkov <93079612+codedeliveryservice@users.noreply.github.com> Date: Thu, 28 May 2026 18:59:45 +0300 Subject: [PATCH] Bench: 2756239 --- src/board.rs | 4 ++-- src/board/parser.rs | 2 +- src/nnue.rs | 6 +++--- src/search.rs | 13 ++++++++----- src/threadpool.rs | 2 +- src/types/bitboard.rs | 8 ++++---- src/types/castling.rs | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/board.rs b/src/board.rs index f8f795f7d..79ef5ebbb 100644 --- a/src/board.rs +++ b/src/board.rs @@ -249,7 +249,7 @@ impl Board { } pub fn has_repeated(&self) -> bool { - let end = self.state.plies_from_null.min(self.state.fiftymove_clock as usize); + let end = self.state.plies_from_null.min(self.fiftymove_clock() as usize); self.state_stack.iter().rev().take(end.saturating_sub(3)).any(|s| s.repetition != 0) } @@ -269,7 +269,7 @@ impl Board { /// /// pub fn upcoming_repetition(&self, ply: usize) -> bool { - let half_moves = self.state.plies_from_null.min(self.state.fiftymove_clock as usize); + let half_moves = self.state.plies_from_null.min(self.fiftymove_clock() as usize); if half_moves < 3 { return false; } diff --git a/src/board/parser.rs b/src/board/parser.rs index ff6b4ac30..f3ca8087d 100644 --- a/src/board/parser.rs +++ b/src/board/parser.rs @@ -151,7 +151,7 @@ impl Board { fen.push(' '); fen.push_str(&self.state.en_passant.to_string()); fen.push(' '); - fen.push_str(&self.state.fiftymove_clock.to_string()); + fen.push_str(&self.fiftymove_clock().to_string()); fen.push(' '); fen.push_str(&self.fullmove_number().to_string()); fen diff --git a/src/nnue.rs b/src/nnue.rs index 0f3cd84bb..fa9c6fa26 100644 --- a/src/nnue.rs +++ b/src/nnue.rs @@ -336,18 +336,18 @@ pub struct Parameters { } impl Parameters { - fn embedded() -> &'static Parameters { + fn embedded() -> &'static Self { static EMBEDDED: Parameters = unsafe { std::mem::transmute(*include_bytes!(env!("MODEL"))) }; &EMBEDDED } fn allocate_owned() -> Arc { - let mut boxed = Box::>::new(std::mem::MaybeUninit::uninit()); + let mut boxed = Box::>::new(std::mem::MaybeUninit::uninit()); let ptr = boxed.as_mut_ptr(); std::mem::forget(boxed); unsafe { - std::ptr::copy_nonoverlapping(Self::embedded() as *const Parameters, ptr, 1); + std::ptr::copy_nonoverlapping(Self::embedded() as *const Self, ptr, 1); Arc::from(Box::from_raw(ptr)) } } diff --git a/src/search.rs b/src/search.rs index 9ce8e559f..ef5706aac 100644 --- a/src/search.rs +++ b/src/search.rs @@ -715,11 +715,13 @@ fn search( continue; } - move_count += 1; current_search_count = 0; + + move_count += 1; td.stack[ply].move_count = move_count; let is_quiet = mv.is_quiet(); + let is_direct_check = td.board.is_direct_check(mv); let history = if is_quiet { td.quiet_history.get(td.board.all_threats(), stm, mv) + td.conthist(ply, 1, mv) + td.conthist(ply, 2, mv) @@ -731,7 +733,7 @@ fn search( if !NODE::ROOT && !is_loss(best_score) { // Late Move Pruning (LMP) if !in_check - && !td.board.is_direct_check(mv) + && !is_direct_check && is_quiet && !is_win(beta) && move_count as i32 @@ -749,7 +751,7 @@ fn search( + 542 * correction_value.abs() / 1024 - 135; - if !in_check && is_quiet && depth < 16 && futility_value <= alpha && !td.board.is_direct_check(mv) { + if !in_check && !is_direct_check && is_quiet && depth < 16 && futility_value <= alpha { if !is_decisive(best_score) && best_score < futility_value { best_score = futility_value; } @@ -761,10 +763,10 @@ fn search( let noisy_futility_value = eval + 80 * depth + 71 * history / 1024 + 24; if !in_check + && !is_direct_check && depth < 11 && move_picker.stage() == Stage::BadNoisy && noisy_futility_value <= alpha - && !td.board.is_direct_check(mv) { if !is_decisive(best_score) && best_score < noisy_futility_value { best_score = noisy_futility_value; @@ -1193,10 +1195,11 @@ fn qsearch(td: &mut ThreadData, mut alpha: i32, beta: i32, ply: } } + let correction_value = eval_correction(td, ply); + let raw_eval; let eval; let mut best_score; - let correction_value = eval_correction(td, ply); // Evaluation if in_check { diff --git a/src/threadpool.rs b/src/threadpool.rs index ab46e17cf..900e13b85 100644 --- a/src/threadpool.rs +++ b/src/threadpool.rs @@ -43,7 +43,7 @@ impl ThreadPool { } pub fn set_count(&mut self, threads: usize) { - let threads = threads.clamp(1, ThreadPool::available_threads()); + let threads = threads.clamp(1, Self::available_threads()); let shared = self.vector[0].shared.clone(); shared.numa_context.set_thread_count(threads); diff --git a/src/types/bitboard.rs b/src/types/bitboard.rs index d200271a3..a425554d2 100644 --- a/src/types/bitboard.rs +++ b/src/types/bitboard.rs @@ -13,11 +13,11 @@ impl Bitboard { pub const ALL: Self = Self(0xFFFFFFFFFFFFFFFF); pub const LIGHT_SQUARES: Self = Self(0x55AA55AA55AA55AA); pub const BOTH_HOME_ROWS: Self = Self(0xFF000000000000FF); - pub const SIXTH_RANK: [Bitboard; 2] = [Self::rank(Rank::R6), Self::rank(Rank::R3)]; - pub const THIRD_RANK: [Bitboard; 2] = [Self::rank(Rank::R3), Self::rank(Rank::R6)]; - pub const HOME_ROWS: [Bitboard; 2] = [Self::rank(Rank::R1), Self::rank(Rank::R8)]; + pub const SIXTH_RANK: [Self; 2] = [Self::rank(Rank::R6), Self::rank(Rank::R3)]; + pub const THIRD_RANK: [Self; 2] = [Self::rank(Rank::R3), Self::rank(Rank::R6)]; + pub const HOME_ROWS: [Self; 2] = [Self::rank(Rank::R1), Self::rank(Rank::R8)]; pub const CORNERS: Self = Self(0x8100000000000081); - pub const LEVER_RANKS: [Bitboard; 2] = [Self(0x0000FFFF00000000), Self(0x00000000FFFF0000)]; + pub const LEVER_RANKS: [Self; 2] = [Self(0x0000FFFF00000000), Self(0x00000000FFFF0000)]; /// Creates a bitboard with all bits set in the specified rank. pub const fn rank(rank: Rank) -> Self { diff --git a/src/types/castling.rs b/src/types/castling.rs index 74e44f83a..67686d212 100644 --- a/src/types/castling.rs +++ b/src/types/castling.rs @@ -12,7 +12,7 @@ pub enum CastlingKind { } impl CastlingKind { - pub const KINDS: [[CastlingKind; 2]; 2] = + pub const KINDS: [[Self; 2]; 2] = [[Self::WhiteQueenside, Self::WhiteKingside], [Self::BlackQueenside, Self::BlackKingside]]; pub const fn landing_square(self) -> Square {