diff --git a/src/Lynx/EvaluationConstants.cs b/src/Lynx/EvaluationConstants.cs index 81eaf39b4..7d6feaec5 100644 --- a/src/Lynx/EvaluationConstants.cs +++ b/src/Lynx/EvaluationConstants.cs @@ -336,6 +336,7 @@ static EvaluationConstants() public const int ThirdKillerMoveValue = 131_072; + // Revisit bad capture pruning in NegaMax.cs if order changes and promos aren't the lowest before bad captures public const int PromotionMoveScoreValue = 65_536; public const int BadCaptureMoveBaseScoreValue = 32_768; diff --git a/src/Lynx/Search/NegaMax.cs b/src/Lynx/Search/NegaMax.cs index cce57a386..3d4920446 100644 --- a/src/Lynx/Search/NegaMax.cs +++ b/src/Lynx/Search/NegaMax.cs @@ -1,4 +1,5 @@ using Lynx.Model; +using System.Transactions; namespace Lynx; @@ -452,6 +453,12 @@ public int QuiescenceSearch(int ply, int alpha, int beta) var move = pseudoLegalMoves[i]; + // Prune bad captures + if (scores[i] < EvaluationConstants.PromotionMoveScoreValue && scores[i] >= EvaluationConstants.BadCaptureMoveBaseScoreValue) + { + continue; + } + var gameState = position.MakeMove(move); if (!position.WasProduceByAValidMove()) { diff --git a/tests/Lynx.Test/EvaluationConstantsTest.cs b/tests/Lynx.Test/EvaluationConstantsTest.cs index 0e0cd90dc..46fa4540b 100644 --- a/tests/Lynx.Test/EvaluationConstantsTest.cs +++ b/tests/Lynx.Test/EvaluationConstantsTest.cs @@ -172,6 +172,25 @@ public void ThirdKillerMoveValueConstant() Assert.Greater(ThirdKillerMoveValue, default); } + [Test] + public void PromotionMoveValueConstant() + { + var maxMVVLVAMoveValue = int.MinValue; + + for (int s = (int)Piece.P; s <= (int)Piece.r; ++s) + { + for (int t = (int)Piece.P; t <= (int)Piece.r; ++t) + { + if (MostValueableVictimLeastValuableAttacker[s, t] > maxMVVLVAMoveValue) + { + maxMVVLVAMoveValue = MostValueableVictimLeastValuableAttacker[s, t]; + } + } + } + + Assert.Less(BadCaptureMoveBaseScoreValue + maxMVVLVAMoveValue, PromotionMoveScoreValue); + } + /// /// Avoids drawish evals that can lead the GUI to declare a draw /// or negative ones that can lead it to resign