Skip to content

Commit

Permalink
scale null move reductions with depth remaining
Browse files Browse the repository at this point in the history
Rank Name                          Elo     +/-   Games    Wins  Losses   Draws   Points   Score    Draw
   0 dev                           -48       6    9000    2369    3617    3014   3876.0   43.1%   33.5%
   1 Nalwald-18                     75      10    3000    1267     631    1102   1818.0   60.6%   36.7%
   2 Counter-5.0                    56      10    3000    1295     812     893   1741.5   58.1%   29.8%
   3 StockNemo-5.7                  15      10    3000    1055     926    1019   1564.5   52.1%   34.0%
  • Loading branch information
brunocodutra committed Dec 16, 2023
1 parent 0e58df7 commit 2e74785
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ impl Engine {
/// An implementation of [null move pruning].
///
/// [null move pruning]: https://www.chessprogramming.org/Null_Move_Pruning
fn nmp(&self, pos: &Position, guess: Score, beta: Score, depth: Depth) -> Option<Depth> {
fn nmp(
&self,
pos: &Position,
guess: Score,
beta: Score,
depth: Depth,
ply: Ply,
) -> Option<Depth> {
let turn = pos.turn();
let r = match pos.by_color(turn).len() - pos.by_piece(Piece(turn, Role::Pawn)).len() {
..=1 => return None,
2 => 2,
3 => 3,
_ => 4,
};

if guess > beta {
Some(depth - r)
let pawn = Piece(turn, Role::Pawn);
if guess > beta && pos.by_color(turn).len() - pos.by_piece(pawn).len() > 1 {
Some(depth - 2 - (depth - ply) / 4)
} else {
None
}
Expand Down Expand Up @@ -213,7 +214,7 @@ impl Engine {
if ply >= Ply::UPPER {
return Ok(Pv::new(score, []));
} else if !is_pv && !in_check {
if let Some(d) = self.nmp(pos, score, beta, depth) {
if let Some(d) = self.nmp(pos, score, beta, depth, ply) {
let mut next = pos.clone();
next.pass();
if d <= ply || -self.nw(&next, -beta + 1, d, ply + 1, ctrl)? >= beta {
Expand Down

0 comments on commit 2e74785

Please sign in to comment.