From dd79dc61ba32eeb0e04fbbf31199d335c98503f1 Mon Sep 17 00:00:00 2001 From: stefiosif Date: Thu, 13 Feb 2025 20:37:12 +0200 Subject: [PATCH] Add RFP --- src/search/negamax.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/search/negamax.rs b/src/search/negamax.rs index 890fe4d..c5ff59c 100644 --- a/src/search/negamax.rs +++ b/src/search/negamax.rs @@ -2,7 +2,7 @@ use anyhow::{bail, Result}; use crate::{ board::game::Game, - evaluation::{MATE_SCORE, MIN_SCORE}, + evaluation::{pesto::pesto, MATE_SCORE, MIN_SCORE}, }; use super::{ @@ -54,6 +54,21 @@ pub fn negamax( } } + const RFP_DEPTH: u8 = 5; + const RFP_MARGIN: u8 = 75; + let eval = entry + .map(|entry| entry.score) + .unwrap_or_else(|| pesto().eval(game)); + + if !in_check + && alpha == beta - 1 + && depth <= RFP_DEPTH + && eval > beta + && eval - (RFP_MARGIN * depth) as i16 > beta + { + return Ok(eval); + } + if plies != 0 && !in_check && depth >= 3 && do_nmp && game.board.non_pawn_materials() > 0 { game.make_null_move(); let score = -negamax(