From a65397692a7d1bc1c3e07977481036f642872e1e Mon Sep 17 00:00:00 2001 From: Bruno Dutra Date: Fri, 23 Aug 2024 14:38:52 +0200 Subject: [PATCH] reduce Value range to +-4000 --- lib/nnue.rs | 2 +- lib/nnue/material.rs | 2 +- lib/nnue/positional.rs | 2 +- lib/nnue/value.rs | 2 +- lib/search/engine.rs | 12 ++++++------ lib/search/ply.rs | 2 +- lib/search/score.rs | 4 ++-- lib/search/transposition.rs | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/nnue.rs b/lib/nnue.rs index 576c08ba..91ce961d 100644 --- a/lib/nnue.rs +++ b/lib/nnue.rs @@ -103,7 +103,7 @@ mod tests { for weights in features.array_chunks_mut::<768>() { let (small, _, _) = weights.select_nth_unstable(32); assert!(small.iter().fold(bias, |s, &v| s + v).abs() <= i16::MAX as i32); - let (_, _, large) = weights.select_nth_unstable(Positional::LEN - 33); + let (_, _, large) = weights.select_nth_unstable(735); assert!(large.iter().fold(bias, |s, &v| s + v).abs() <= i16::MAX as i32); } }); diff --git a/lib/nnue/material.rs b/lib/nnue/material.rs index 5b06eecc..111ad2a9 100644 --- a/lib/nnue/material.rs +++ b/lib/nnue/material.rs @@ -44,7 +44,7 @@ impl Accumulator for Material { #[inline(always)] fn evaluate(&self, turn: Color, phase: usize) -> i32 { - (self.0[turn as usize][phase] - self.0[turn.flip() as usize][phase]) / 32 + (self.0[turn as usize][phase] - self.0[turn.flip() as usize][phase]) / 80 } } diff --git a/lib/nnue/positional.rs b/lib/nnue/positional.rs index 5ab0c108..60f5c1a7 100644 --- a/lib/nnue/positional.rs +++ b/lib/nnue/positional.rs @@ -44,7 +44,7 @@ impl Accumulator for Positional { #[inline(always)] fn evaluate(&self, turn: Color, phase: usize) -> i32 { - Nnue::hidden(phase).forward([&self.0[turn as usize], &self.0[turn.flip() as usize]]) / 16 + Nnue::hidden(phase).forward([&self.0[turn as usize], &self.0[turn.flip() as usize]]) / 40 } } diff --git a/lib/nnue/value.rs b/lib/nnue/value.rs index b1718fc3..e63e558b 100644 --- a/lib/nnue/value.rs +++ b/lib/nnue/value.rs @@ -9,7 +9,7 @@ pub struct ValueRepr(#[cfg_attr(test, strategy(Self::MIN..=Self::MAX))] Option { - let bounds = -(alpha - 60)..-(alpha - 401); + let bounds = -(alpha - 24)..-(alpha - 161); let r = match (alpha + next.clone().see(m.whither(), bounds)).get() { - ..=60 => return None, - 61..=200 => 1, - 201..=400 => 2, + ..=24 => return None, + 25..=80 => 1, + 81..=160 => 2, _ => 3, }; @@ -222,7 +222,7 @@ impl Engine { if Some(m) == transposition.map(|t| t.best()) { (m, Value::upper()) } else if Self::KILLERS.with_borrow(|ks| ks.contains(ply, pos.turn(), m)) { - (m, Value::new(100)) + (m, Value::new(40)) } else if m.is_quiet() { (m, Value::new(0)) } else { @@ -308,7 +308,7 @@ impl Engine { 'id: for d in depth.get()..=limit.get() { let mut overtime = time.end - time.start; let mut depth = Depth::new(d); - let mut delta: i16 = 24; + let mut delta: i16 = 10; let (mut lower, mut upper) = match d { ..=4 => (Score::lower(), Score::upper()), diff --git a/lib/search/ply.rs b/lib/search/ply.rs index 47a956f4..6efd4b69 100644 --- a/lib/search/ply.rs +++ b/lib/search/ply.rs @@ -11,7 +11,7 @@ unsafe impl Integer for PlyRepr { const MIN: Self::Repr = -Self::MAX; #[cfg(not(test))] - const MAX: Self::Repr = 127; + const MAX: Self::Repr = 95; #[cfg(test)] const MAX: Self::Repr = 3; diff --git a/lib/search/score.rs b/lib/search/score.rs index dd758814..acf77934 100644 --- a/lib/search/score.rs +++ b/lib/search/score.rs @@ -10,7 +10,7 @@ pub struct ScoreRepr(#[cfg_attr(test, strategy(Self::MIN..=Self::MAX))] ; + type Bits = Bits; #[inline(always)] fn encode(&self) -> Self::Bits { diff --git a/lib/search/transposition.rs b/lib/search/transposition.rs index f2f5c60c..a8c7dba6 100644 --- a/lib/search/transposition.rs +++ b/lib/search/transposition.rs @@ -102,7 +102,7 @@ impl Transposition { } impl Binary for Transposition { - type Bits = Bits; + type Bits = Bits; #[inline(always)] fn encode(&self) -> Self::Bits { @@ -125,7 +125,7 @@ impl Binary for Transposition { } } -type Signature = Bits; +type Signature = Bits; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] #[cfg_attr(test, derive(test_strategy::Arbitrary))]