diff --git a/src/Lynx/EvaluationConstants.cs b/src/Lynx/EvaluationConstants.cs index d9b08314b..0861445de 100644 --- a/src/Lynx/EvaluationConstants.cs +++ b/src/Lynx/EvaluationConstants.cs @@ -312,6 +312,10 @@ static EvaluationConstants() /// public const int NegativeCheckmateDetectionLimit = -27_000; // -CheckMateBaseEvaluation + (Constants.AbsoluteMaxDepth + 45) * DepthCheckmateFactor; + public const int MinEval = NegativeCheckmateDetectionLimit + 1; + + public const int MaxEval = PositiveCheckmateDetectionLimit - 1; + public const int PVMoveScoreValue = 4_194_304; public const int TTMoveScoreValue = 2_097_152; diff --git a/src/Lynx/Model/Position.cs b/src/Lynx/Model/Position.cs index 336501655..054a094e3 100644 --- a/src/Lynx/Model/Position.cs +++ b/src/Lynx/Model/Position.cs @@ -693,6 +693,8 @@ public string FEN(int halfMovesWithoutCaptureOrPawnMove = 0, int fullMoveClock = var eval = ((middleGameScore * gamePhase) + (endGameScore * endGamePhase)) / maxPhase; + eval = Math.Clamp(eval, EvaluationConstants.MinEval, EvaluationConstants.MaxEval); + var sideEval = Side == Side.White ? eval : -eval;