diff --git a/src/Lynx/EvaluationConstants.cs b/src/Lynx/EvaluationConstants.cs index 5a1528ae7..d9b08314b 100644 --- a/src/Lynx/EvaluationConstants.cs +++ b/src/Lynx/EvaluationConstants.cs @@ -9,14 +9,20 @@ namespace Lynx; public static class EvaluationConstants { /// - /// 30k games, 16+0.16, UHO_XXL_+0.90_+1.19.epd - /// Retained (W,D,L) = (791773, 1127929, 793778) positions. + /// 21454 games, 16+0.16, UHO_XXL_+0.90_+1.19.epd + /// Retained (W,D,L) = (486074, 1108791, 487345) positions. /// - public const int EvalNormalizationCoefficient = 78; + public const int EvalNormalizationCoefficient = 138; - public static readonly double[] As = [-44.54789428, 284.90322556, -305.65458204, 143.86777995]; + public static readonly double[] As = [-25.59900221, 175.23377472, -145.09355540, 133.49051930]; - public static readonly double[] Bs = [-21.08101051, 127.81742295, -160.22340655, 128.53122955]; + public static readonly double[] Bs = [-14.14613328, 84.98205725, -101.16332276, 120.88906952]; + + public static readonly int[] GamePhaseByPiece = + [ + 0, 1, 1, 2, 4, 0, + 0, 1, 1, 2, 4, 0 + ]; public static readonly int[] MiddleGamePieceValues = [ @@ -30,12 +36,6 @@ public static class EvaluationConstants -109, -356, -324, -653, -1123, 0 ]; - public static readonly int[] GamePhaseByPiece = -[ - 0, 1, 1, 2, 4, 0, - 0, 1, 1, 2, 4, 0 -]; - public static readonly int[] MiddleGamePawnTable = [ 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/tests/Lynx.Test/WDLTest.cs b/tests/Lynx.Test/WDLTest.cs index a971c1160..ca03a8030 100644 --- a/tests/Lynx.Test/WDLTest.cs +++ b/tests/Lynx.Test/WDLTest.cs @@ -16,8 +16,13 @@ public void NormalizeCoefficientAndArrayValues() Assert.AreEqual(EvaluationConstants.EvalNormalizationCoefficient, (int)EvaluationConstants.As.Sum()); } - [TestCase(500, 641)] - [TestCase(1000, 1282)] + [TestCase(500)] + [TestCase(1000)] + public void NormalizeScore(int score) + { + Assert.AreEqual(score * 100 / EvaluationConstants.EvalNormalizationCoefficient, WDL.NormalizeScore(score)); + } + [TestCase(0, 0)] [TestCase(EvaluationConstants.PositiveCheckmateDetectionLimit + 5, EvaluationConstants.PositiveCheckmateDetectionLimit + 5)] [TestCase(EvaluationConstants.NegativeCheckmateDetectionLimit - 5, EvaluationConstants.NegativeCheckmateDetectionLimit - 5)] @@ -26,8 +31,13 @@ public void NormalizeScore(int score, int expectecNormalizedEval) Assert.AreEqual(expectecNormalizedEval, WDL.NormalizeScore(score)); } - [TestCase(1000, 780)] - [TestCase(2000, 1560)] + [TestCase(1000)] + [TestCase(2000)] + public void UnNormalizeScore(int score) + { + Assert.AreEqual(score * EvaluationConstants.EvalNormalizationCoefficient / 100, WDL.UnNormalizeScore(score)); + } + [TestCase(0, 0)] [TestCase(EvaluationConstants.PositiveCheckmateDetectionLimit + 5, EvaluationConstants.PositiveCheckmateDetectionLimit + 5)] [TestCase(EvaluationConstants.NegativeCheckmateDetectionLimit - 5, EvaluationConstants.NegativeCheckmateDetectionLimit - 5)]