Skip to content

Commit

Permalink
scale evaluation down by 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocodutra committed Nov 8, 2024
1 parent ac27530 commit 7a4c9e0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
3 changes: 2 additions & 1 deletion lib/nnue/evaluator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ impl<T: Accumulator> Evaluator<T> {
/// The [`Position`]'s evaluation.
pub fn evaluate(&self) -> Value {
let phase = (self.occupied().len() - 1) / 4;
self.acc.evaluate(self.turn(), phase).saturate()
let value = self.acc.evaluate(self.turn(), phase) >> 8;
value.saturate()
}

/// The Static Exchange Evaluation ([SEE]) algorithm.
Expand Down
4 changes: 1 addition & 3 deletions lib/nnue/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ impl Accumulator for Material {

#[inline(always)]
fn evaluate(&self, turn: Color, phase: usize) -> i32 {
let us = self.0[turn as usize];
let them = self.0[turn.flip() as usize];
(us.get(phase).assume() - them.get(phase).assume()) / 80
self.0[turn as usize].get(phase).assume() - self.0[turn.flip() as usize].get(phase).assume()
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/nnue/positional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]) / 40
Nnue::hidden(phase).forward(&self.0[turn as usize], &self.0[turn.flip() as usize]) << 1
}
}

Expand Down
13 changes: 6 additions & 7 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ impl Engine {
depth: Depth,
ply: Ply,
) -> Option<Depth> {
let bounds = -(alpha - 24)..-(alpha - 161);
let r = match (alpha + next.clone().see(m.whither(), bounds)).get() {
..=24 => return None,
25..=80 => 1,
81..=160 => 2,
let r = match (alpha + next.clone().see(m.whither(), -(alpha - 8)..-(alpha - 49))).get() {
..=8 => return None,
9..=24 => 1,
25..=48 => 2,
_ => 3,
};

Expand Down Expand Up @@ -223,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(40))
(m, Value::new(16))
} else if m.is_quiet() {
(m, Value::new(0))
} else {
Expand Down Expand Up @@ -309,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 = 10;
let mut delta: i16 = 4;

let (mut lower, mut upper) = match d {
..=4 => (Score::lower(), Score::upper()),
Expand Down

0 comments on commit 7a4c9e0

Please sign in to comment.