Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -269,7 +269,7 @@ impl Board {
///
/// <http://web.archive.org/web/20201107002606/https://marcelk.net/2013-04-06/paper/upcoming-rep-v2.pdf>
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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/board/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/nnue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self> {
let mut boxed = Box::<std::mem::MaybeUninit<Parameters>>::new(std::mem::MaybeUninit::uninit());
let mut boxed = Box::<std::mem::MaybeUninit<Self>>::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))
}
}
Expand Down
13 changes: 8 additions & 5 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,11 +715,13 @@ fn search<NODE: NodeType>(
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)
Expand All @@ -731,7 +733,7 @@ fn search<NODE: NodeType>(
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
Expand All @@ -749,7 +751,7 @@ fn search<NODE: NodeType>(
+ 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;
}
Expand All @@ -761,10 +763,10 @@ fn search<NODE: NodeType>(
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;
Expand Down Expand Up @@ -1193,10 +1195,11 @@ fn qsearch<NODE: NodeType>(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 {
Expand Down
2 changes: 1 addition & 1 deletion src/threadpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/types/bitboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/types/castling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading