Skip to content

Commit

Permalink
Implement QS FP
Browse files Browse the repository at this point in the history
  • Loading branch information
eduherminio committed May 16, 2024
1 parent 62235ec commit c48586d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Lynx.Cli/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"FP_DepthScalingFactor": 60,
"FP_Margin": 250,

"DeltaPruning_Margin": 200,
"FP_QS_Margin": 75,

// Evaluation
"DoubledPawnPenalty": {
Expand Down
2 changes: 1 addition & 1 deletion src/Lynx/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public sealed class EngineSettings
public int FP_Margin { get; set; } = 250;

[SPSAAttribute<int>(0, 500, 25)]
public int DeltaPruning_Margin { get; set; } = 200;
public int FP_QS_Margin { get; set; } = 75;

#region Evaluation

Expand Down
2 changes: 1 addition & 1 deletion src/Lynx/SEE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static bool HasPositiveScore(Position position, Move move, int threshold
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Gain(Move move)
private static int Gain(Move move)
{
if (move.IsCastle())
{
Expand Down
9 changes: 4 additions & 5 deletions src/Lynx/Search/NegaMax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -559,12 +559,11 @@ public int QuiescenceSearch(int ply, int alpha, int beta)
continue;
}

// Delta pruning
// If the captured piece SEE value + stand pat + some the margin aren't enough to raise alpha, this move and the following ones
// (which should have lower SEE value) are unlikely to improve
if (standPat + SEE.Gain(move) + Configuration.EngineSettings.DeltaPruning_Margin < alpha)
// QS Futility Pruning (FP)
// Moves without potential to raise alpha are discarded
if (!position.IsInCheck() && standPat + Configuration.EngineSettings.FP_QS_Margin < alpha && !SEE.HasPositiveScore(position, move))
{
return alpha;
continue;
}

var gameState = position.MakeMove(move);
Expand Down

0 comments on commit c48586d

Please sign in to comment.