Skip to content

Commit

Permalink
tweak late move pruning margins
Browse files Browse the repository at this point in the history
Rank Name                          Elo     +/-   Games    Wins  Losses   Draws   Points   Score    Draw
   0 dev                           -29       6    9000    2586    3330    3084   4128.0   45.9%   34.3%
   1 Nalwald-18                     58      10    3000    1200     703    1097   1748.5   58.3%   36.6%
   2 Counter-5.0                    30      10    3000    1171     916     913   1627.5   54.3%   30.4%
   3 StockNemo-5.7                  -1      10    3000     959     967    1074   1496.0   49.9%   35.8%
  • Loading branch information
brunocodutra committed Dec 31, 2023
1 parent 2e74785 commit d4a02c8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/search/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,23 @@ impl Engine {
/// An implementation of [late move pruning].
///
/// [late move pruning]: https://www.chessprogramming.org/Late_Move_Reductions
fn lmp(&self, next: &Position, guess: Score, alpha: Score, depth: Depth) -> Option<Depth> {
fn lmp(
&self,
next: &Position,
guess: Score,
alpha: Score,
depth: Depth,
ply: Ply,
) -> Option<Depth> {
let r = match (alpha - guess).get() {
..=90 => return None,
91..=270 => 1,
271..=810 => 2,
811..=2430 => 3,
2431..=7290 => 4,
_ => 5,
..=60 => return None,
61..=180 => 1,
181..=500 => 2,
_ => 3,
};

if !next.is_check() {
Some(depth - r)
Some(depth - r - (depth - ply) / 4)
} else {
None
}
Expand Down Expand Up @@ -286,7 +291,7 @@ impl Engine {

if !in_check && gain < 60 {
let guess = -next.clone().see(m.whither()).cast();
if let Some(d) = self.lmp(&next, guess, alpha, depth) {
if let Some(d) = self.lmp(&next, guess, alpha, depth, ply) {
if d <= ply || -self.nw(&next, -alpha, d, ply + 1, ctrl)? <= alpha {
#[cfg(not(test))]
// The late move pruning heuristic is not exact.
Expand Down

0 comments on commit d4a02c8

Please sign in to comment.