From 4481947470ca555e6cbdb7df551c80532eca0c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Sun, 5 Jan 2025 18:21:35 +0100 Subject: [PATCH] Add history component to RFP --- src/Lynx/Configuration.cs | 3 +++ src/Lynx/Search/NegaMax.cs | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Lynx/Configuration.cs b/src/Lynx/Configuration.cs index a4df158a8..370c8d8c0 100644 --- a/src/Lynx/Configuration.cs +++ b/src/Lynx/Configuration.cs @@ -186,6 +186,9 @@ public int Threads [SPSA(1, 300, 15)] public int RFP_DepthScalingFactor { get; set; } = 52; + [SPSA(200, 600, 20)] + public int RFP_HistoryDivisor { get; set; } = 400; + [SPSA(1, 10, 0.5)] public int Razoring_MaxDepth { get; set; } = 2; diff --git a/src/Lynx/Search/NegaMax.cs b/src/Lynx/Search/NegaMax.cs index 028abb81d..41b143e92 100644 --- a/src/Lynx/Search/NegaMax.cs +++ b/src/Lynx/Search/NegaMax.cs @@ -148,8 +148,10 @@ private int NegaMax(int depth, int ply, int alpha, int beta, bool cutnode, Cance var improvingFactor = improvingRate * (0.75 * depth); var rfpThreshold = rfpMargin + improvingFactor; + var previousMove = Game.ReadMoveFromStack(ply - 1); + var previousMoveHistory = _quietHistory[previousMove.Piece()][previousMove.TargetSquare()]; - if (staticEval - rfpThreshold >= beta) + if (staticEval - rfpThreshold >= beta + previousMoveHistory / Configuration.EngineSettings.RFP_HistoryDivisor) { #pragma warning disable S3949 // Calculations should not overflow - value is being set at the beginning of the else if (!pvNode) return (staticEval + beta) / 2;