From 309700e2ee3e8b59138209a11685a211d809c683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20C=C3=A1ceres?= Date: Sat, 7 Sep 2024 14:03:53 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20=20Replace=20Chebyshev=20distance?= =?UTF-8?q?=20calculation=20with=20lookup=20table=20(double=20array)=20(#9?= =?UTF-8?q?57)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ChebyshevDistance_Benchmark.cs | 340 ++++++++++++++++++ src/Lynx/Constants.cs | 71 ++++ src/Lynx/Model/Position.cs | 4 +- src/Lynx/Utils.cs | 15 - tests/Lynx.Test/Model/PositionTest.cs | 4 +- tests/Lynx.Test/UtilsTest.cs | 2 +- 6 files changed, 416 insertions(+), 20 deletions(-) create mode 100644 src/Lynx.Benchmark/ChebyshevDistance_Benchmark.cs diff --git a/src/Lynx.Benchmark/ChebyshevDistance_Benchmark.cs b/src/Lynx.Benchmark/ChebyshevDistance_Benchmark.cs new file mode 100644 index 000000000..1473baf52 --- /dev/null +++ b/src/Lynx.Benchmark/ChebyshevDistance_Benchmark.cs @@ -0,0 +1,340 @@ +/* + * + * BenchmarkDotNet v0.14.0, Ubuntu 22.04.4 LTS (Jammy Jellyfish) + * AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores + * .NET SDK 8.0.401 + * [Host] : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * DefaultJob : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * + * | Method | sq1Array | sq2Array | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | + * |------------------ |---------- |---------- |--------------:|-----------:|-----------:|-------:|--------:|----------:|------------:| + * | OnTheFly | Int32[10] | Int32[10] | 199.543 ns | 2.4357 ns | 2.2783 ns | 1.000 | 0.02 | - | NA | + * | Lookup | Int32[10] | Int32[10] | 64.915 ns | 0.1788 ns | 0.1396 ns | 0.325 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[10] | Int32[10] | 68.922 ns | 0.6394 ns | 0.5668 ns | 0.345 | 0.00 | - | NA | + * | OnTheFly | Int32[1] | Int32[1] | 2.012 ns | 0.0198 ns | 0.0175 ns | 0.010 | 0.00 | - | NA | + * | Lookup | Int32[1] | Int32[1] | 1.380 ns | 0.0131 ns | 0.0116 ns | 0.007 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[1] | Int32[1] | 1.683 ns | 0.0056 ns | 0.0044 ns | 0.008 | 0.00 | - | NA | + * | OnTheFly | Int32[30] | Int32[30] | 1,735.268 ns | 16.5898 ns | 13.8532 ns | 8.697 | 0.12 | - | NA | + * | Lookup | Int32[30] | Int32[30] | 592.591 ns | 2.6362 ns | 2.2014 ns | 2.970 | 0.03 | - | NA | + * | LookupDoubleArray | Int32[30] | Int32[30] | 593.276 ns | 0.7367 ns | 0.6152 ns | 2.974 | 0.03 | - | NA | + * | OnTheFly | Int32[5] | Int32[5] | 50.485 ns | 0.3470 ns | 0.3076 ns | 0.253 | 0.00 | - | NA | + * | Lookup | Int32[5] | Int32[5] | 18.613 ns | 0.2392 ns | 0.2238 ns | 0.093 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[5] | Int32[5] | 18.617 ns | 0.1388 ns | 0.1298 ns | 0.093 | 0.00 | - | NA | + * | OnTheFly | Int32[64] | Int32[64] | 10,995.924 ns | 19.2642 ns | 17.0772 ns | 55.112 | 0.62 | - | NA | + * | Lookup | Int32[64] | Int32[64] | 2,623.785 ns | 23.7809 ns | 22.2446 ns | 13.151 | 0.18 | - | NA | + * | LookupDoubleArray | Int32[64] | Int32[64] | 2,608.702 ns | 5.1225 ns | 4.2775 ns | 13.075 | 0.15 | - | NA | + * + * + * BenchmarkDotNet v0.14.0, Windows 10 (10.0.20348.2655) (Hyper-V) + * AMD EPYC 7763, 1 CPU, 4 logical and 2 physical cores + * .NET SDK 8.0.401 + * [Host] : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * DefaultJob : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * + * | Method | sq1Array | sq2Array | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | + * |------------------ |---------- |---------- |-------------:|----------:|----------:|-------:|--------:|----------:|------------:| + * | OnTheFly | Int32[10] | Int32[10] | 182.940 ns | 0.6388 ns | 0.4987 ns | 1.000 | 0.00 | - | NA | + * | Lookup | Int32[10] | Int32[10] | 64.521 ns | 0.1274 ns | 0.0994 ns | 0.353 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[10] | Int32[10] | 70.411 ns | 0.7159 ns | 0.6697 ns | 0.385 | 0.00 | - | NA | + * | OnTheFly | Int32[1] | Int32[1] | 2.649 ns | 0.0030 ns | 0.0025 ns | 0.014 | 0.00 | - | NA | + * | Lookup | Int32[1] | Int32[1] | 1.412 ns | 0.0025 ns | 0.0022 ns | 0.008 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[1] | Int32[1] | 1.723 ns | 0.0040 ns | 0.0035 ns | 0.009 | 0.00 | - | NA | + * | OnTheFly | Int32[30] | Int32[30] | 2,102.563 ns | 4.0566 ns | 3.3874 ns | 11.493 | 0.04 | - | NA | + * | Lookup | Int32[30] | Int32[30] | 572.458 ns | 0.4641 ns | 0.4114 ns | 3.129 | 0.01 | - | NA | + * | LookupDoubleArray | Int32[30] | Int32[30] | 582.855 ns | 0.5000 ns | 0.4432 ns | 3.186 | 0.01 | - | NA | + * | OnTheFly | Int32[5] | Int32[5] | 48.996 ns | 0.4039 ns | 0.3581 ns | 0.268 | 0.00 | - | NA | + * | Lookup | Int32[5] | Int32[5] | 16.870 ns | 0.0700 ns | 0.0655 ns | 0.092 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[5] | Int32[5] | 19.678 ns | 0.2548 ns | 0.2383 ns | 0.108 | 0.00 | - | NA | + * | OnTheFly | Int32[64] | Int32[64] | 9,905.736 ns | 9.2500 ns | 8.1999 ns | 54.148 | 0.15 | - | NA | + * | Lookup | Int32[64] | Int32[64] | 2,567.974 ns | 2.3026 ns | 2.0412 ns | 14.037 | 0.04 | - | NA | + * | LookupDoubleArray | Int32[64] | Int32[64] | 2,585.791 ns | 1.5930 ns | 1.3302 ns | 14.135 | 0.04 | - | NA | + * + * + * BenchmarkDotNet v0.14.0, macOS Sonoma 14.6.1 (23G93) [Darwin 23.6.0] + * Apple M1 (Virtual), 1 CPU, 3 logical and 3 physical cores + * .NET SDK 8.0.401 + * [Host] : .NET 8.0.8 (8.0.824.36612), Arm64 RyuJIT AdvSIMD + * DefaultJob : .NET 8.0.8 (8.0.824.36612), Arm64 RyuJIT AdvSIMD + * + * | Method | sq1Array | sq2Array | Mean | Error | StdDev | Ratio | RatioSD | Allocated | Alloc Ratio | + * |------------------ |---------- |---------- |--------------:|-----------:|-----------:|-------:|--------:|----------:|------------:| + * | OnTheFly | Int32[10] | Int32[10] | 203.9593 ns | 0.8891 ns | 0.7882 ns | 1.000 | 0.01 | - | NA | + * | Lookup | Int32[10] | Int32[10] | 55.4638 ns | 1.1100 ns | 1.7281 ns | 0.272 | 0.01 | - | NA | + * | LookupDoubleArray | Int32[10] | Int32[10] | 70.1269 ns | 1.4349 ns | 1.4093 ns | 0.344 | 0.01 | - | NA | + * | OnTheFly | Int32[1] | Int32[1] | 1.4242 ns | 0.0068 ns | 0.0053 ns | 0.007 | 0.00 | - | NA | + * | Lookup | Int32[1] | Int32[1] | 0.8779 ns | 0.0392 ns | 0.0550 ns | 0.004 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[1] | Int32[1] | 1.0344 ns | 0.0223 ns | 0.0186 ns | 0.005 | 0.00 | - | NA | + * | OnTheFly | Int32[30] | Int32[30] | 1,525.1495 ns | 21.4802 ns | 19.0416 ns | 7.478 | 0.09 | - | NA | + * | Lookup | Int32[30] | Int32[30] | 504.5326 ns | 2.3276 ns | 1.8172 ns | 2.474 | 0.01 | - | NA | + * | LookupDoubleArray | Int32[30] | Int32[30] | 588.3407 ns | 2.1516 ns | 1.7967 ns | 2.885 | 0.01 | - | NA | + * | OnTheFly | Int32[5] | Int32[5] | 54.8104 ns | 0.1373 ns | 0.1146 ns | 0.269 | 0.00 | - | NA | + * | Lookup | Int32[5] | Int32[5] | 13.2023 ns | 0.0737 ns | 0.0576 ns | 0.065 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[5] | Int32[5] | 19.4769 ns | 0.0990 ns | 0.0878 ns | 0.095 | 0.00 | - | NA | + * | OnTheFly | Int32[64] | Int32[64] | 7,658.2115 ns | 58.9772 ns | 52.2818 ns | 37.548 | 0.28 | - | NA | + * | Lookup | Int32[64] | Int32[64] | 2,434.3557 ns | 8.8069 ns | 8.2380 ns | 11.936 | 0.06 | - | NA | + * | LookupDoubleArray | Int32[64] | Int32[64] | 2,618.9650 ns | 3.5368 ns | 2.9533 ns | 12.841 | 0.05 | - | NA | + * + * + * BenchmarkDotNet v0.14.0, macOS Ventura 13.6.9 (22G830) [Darwin 22.6.0] + * Intel Core i7-8700B CPU 3.20GHz (Max: 3.19GHz) (Coffee Lake), 1 CPU, 4 logical and 4 physical cores + * .NET SDK 8.0.401 + * [Host] : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * DefaultJob : .NET 8.0.8 (8.0.824.36612), X64 RyuJIT AVX2 + * + * | Method | sq1Array | sq2Array | Mean | Error | StdDev | Median | Ratio | RatioSD | Allocated | Alloc Ratio | + * |------------------ |---------- |---------- |--------------:|------------:|--------------:|--------------:|-------:|--------:|----------:|------------:| + * | OnTheFly | Int32[10] | Int32[10] | 432.910 ns | 25.2507 ns | 73.2570 ns | 405.984 ns | 1.026 | 0.23 | - | NA | + * | Lookup | Int32[10] | Int32[10] | 103.680 ns | 5.5528 ns | 15.8423 ns | 101.424 ns | 0.246 | 0.05 | - | NA | + * | LookupDoubleArray | Int32[10] | Int32[10] | 220.981 ns | 7.1806 ns | 20.3702 ns | 223.290 ns | 0.524 | 0.09 | - | NA | + * | OnTheFly | Int32[1] | Int32[1] | 7.648 ns | 0.5938 ns | 1.6844 ns | 7.342 ns | 0.018 | 0.00 | - | NA | + * | Lookup | Int32[1] | Int32[1] | 2.797 ns | 0.2408 ns | 0.6752 ns | 2.770 ns | 0.007 | 0.00 | - | NA | + * | LookupDoubleArray | Int32[1] | Int32[1] | 4.518 ns | 0.4389 ns | 1.2378 ns | 4.372 ns | 0.011 | 0.00 | - | NA | + * | OnTheFly | Int32[30] | Int32[30] | 4,978.725 ns | 359.7031 ns | 1,032.0557 ns | 4,819.208 ns | 11.796 | 3.04 | - | NA | + * | Lookup | Int32[30] | Int32[30] | 1,173.871 ns | 74.5105 ns | 206.4682 ns | 1,159.219 ns | 2.781 | 0.65 | - | NA | + * | LookupDoubleArray | Int32[30] | Int32[30] | 1,786.069 ns | 119.1448 ns | 341.8487 ns | 1,693.852 ns | 4.232 | 1.03 | - | NA | + * | OnTheFly | Int32[5] | Int32[5] | 111.509 ns | 6.3467 ns | 18.5137 ns | 106.364 ns | 0.264 | 0.06 | - | NA | + * | Lookup | Int32[5] | Int32[5] | 28.691 ns | 1.7239 ns | 4.9740 ns | 27.317 ns | 0.068 | 0.02 | - | NA | + * | LookupDoubleArray | Int32[5] | Int32[5] | 64.047 ns | 2.5143 ns | 7.3741 ns | 62.387 ns | 0.152 | 0.03 | - | NA | + * | OnTheFly | Int32[64] | Int32[64] | 19,400.238 ns | 832.7044 ns | 2,334.9927 ns | 18,673.381 ns | 45.964 | 8.89 | - | NA | + * | Lookup | Int32[64] | Int32[64] | 3,342.320 ns | 83.0324 ns | 235.5490 ns | 3,367.147 ns | 7.919 | 1.32 | - | NA | + * | LookupDoubleArray | Int32[64] | Int32[64] | 5,538.155 ns | 108.5760 ns | 133.3411 ns | 5,576.830 ns | 13.121 | 2.00 | - | NA | + */ + +using BenchmarkDotNet.Attributes; +using System.Runtime.CompilerServices; + +namespace Lynx.Benchmark; +public class ChebyshevDistance_Benchmark : BaseBenchmark +{ + private readonly Random _rnd = new(1234); + + public IEnumerable Data() + { + yield return new object[] { Enumerable.Range(0, 1).Select(_ => _rnd.Next(0, 64)).ToArray(), Enumerable.Range(0, 1).Select(_ => _rnd.Next(0, 64)).ToArray() }; + yield return new object[] { Enumerable.Range(0, 5).Select(_ => _rnd.Next(0, 64)).ToArray(), Enumerable.Range(0, 5).Select(_ => _rnd.Next(0, 64)).ToArray() }; + yield return new object[] { Enumerable.Range(0, 10).Select(_ => _rnd.Next(0, 64)).ToArray(), Enumerable.Range(0, 10).Select(_ => _rnd.Next(0, 64)).ToArray() }; + yield return new object[] { Enumerable.Range(0, 30).Select(_ => _rnd.Next(0, 64)).ToArray(), Enumerable.Range(0, 30).Select(_ => _rnd.Next(0, 64)).ToArray() }; + yield return new object[] { Enumerable.Range(0, 64).Select(_ => _rnd.Next(0, 64)).ToArray(), Enumerable.Range(0, 64).Select(_ => _rnd.Next(0, 64)).ToArray() }; + } + + [Benchmark(Baseline = true)] + [ArgumentsSource(nameof(Data))] + public int OnTheFly(int[] sq1Array, int[] sq2Array) + { + var result = 0; + + for (int sq1 = 0; sq1 < sq1Array.Length; ++sq1) + { + for (int sq2 = 0; sq2 < sq2Array.Length; ++sq2) + { + result += ChebyshevDistanceOnTheFly(sq1Array[sq1], sq2Array[sq2]); + } + } + + return result; + } + + [Benchmark] + [ArgumentsSource(nameof(Data))] + public int Lookup(int[] sq1Array, int[] sq2Array) + { + var result = 0; + + for (int sq1 = 0; sq1 < sq1Array.Length; ++sq1) + { + for (int sq2 = 0; sq2 < sq2Array.Length; ++sq2) + { + result += ChebyshevDistanceLookup(sq1Array[sq1], sq2Array[sq2]); + } + } + + return result; + } + + [Benchmark] + [ArgumentsSource(nameof(Data))] + public int LookupDoubleArray(int[] sq1Array, int[] sq2Array) + { + var result = 0; + + for (int sq1 = 0; sq1 < sq1Array.Length; ++sq1) + { + for (int sq2 = 0; sq2 < sq2Array.Length; ++sq2) + { + result += ChebyshevDistanceLookupDoubleArray(sq1Array[sq1], sq2Array[sq2]); + } + } + + return result; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + private static int ChebyshevDistanceOnTheFly(int square1, int square2) + { + var xDelta = Math.Abs(Lynx.Constants.File[square1] - Lynx.Constants.File[square2]); + var yDelta = Math.Abs(Lynx.Constants.Rank[square1] - Lynx.Constants.Rank[square2]); + + return xDelta >= yDelta + ? xDelta + : yDelta; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int ChebyshevDistanceLookup(int square1, int square2) + { + const int square1Offset = 64; + + return Constants.ChebyshevDistance[(square1 * square1Offset) + square2]; + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static int ChebyshevDistanceLookupDoubleArray(int square1, int square2) + { + return Constants.ChebyshevDistanceDoubleArray[square1][square2]; + } + + public static class Constants + { + /// + /// 64x64 + /// + public static ReadOnlySpan ChebyshevDistance => + [ + 0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 2, 3, 4, 5, 6, 7, 2, 2, 2, 3, 4, 5, 6, 7, 3, 3, 3, 3, 4, 5, 6, 7, 4, 4, 4, 4, 4, 5, 6, 7, 5, 5, 5, 5, 5, 5, 6, 7, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 1, 0, 1, 2, 3, 4, 5, 6, 1, 1, 1, 2, 3, 4, 5, 6, 2, 2, 2, 2, 3, 4, 5, 6, 3, 3, 3, 3, 3, 4, 5, 6, 4, 4, 4, 4, 4, 4, 5, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, + 2, 1, 0, 1, 2, 3, 4, 5, 2, 1, 1, 1, 2, 3, 4, 5, 2, 2, 2, 2, 2, 3, 4, 5, 3, 3, 3, 3, 3, 3, 4, 5, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, + 3, 2,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 1, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3], + [7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 5, 4, 3, 3, 3, 3, 3, 3, 5, 4, 3, 2, 2, 2, 2, 2, 5, 4, 3, 2, 1, 1, 1, 2, 5, 4, 3, 2, 1, 0, 1, 2], + [7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 5, 4, 4, 4, 4, 4, 4, 6, 5, 4, 3, 3, 3, 3, 3, 6, 5, 4, 3, 2, 2, 2, 2, 6, 5, 4, 3, 2, 1, 1, 1, 6, 5, 4, 3, 2, 1, 0, 1], + [7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 6, 5, 5, 5, 5, 5, 5, 7, 6, 5, 4, 4, 4, 4, 4, 7, 6, 5, 4, 3, 3, 3, 3, 7, 6, 5, 4, 3, 2, 2, 2, 7, 6, 5, 4, 3, 2, 1, 1, 7, 6, 5, 4, 3, 2, 1, 0] + ]; + } +} diff --git a/src/Lynx/Constants.cs b/src/Lynx/Constants.cs index 6b8aaf0cd..f11c71c03 100644 --- a/src/Lynx/Constants.cs +++ b/src/Lynx/Constants.cs @@ -377,6 +377,77 @@ public static class Constants /// 500 moves, https://www.chess.com/game/live/378106991 /// public const string SuperLongPositionCommand = "position fen rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 moves e2e4 e7e5 g1f3 g8f6 b1c3 b8c6 f1e2 f8b4 a2a3 b4c3 b2c3 f6e4 e2b5 d7d6 d1e2 e4f6 d2d4 e8g8 d4e5 d6e5 b5c6 b7c6 c1g5 h7h6 g5h4 f8e8 a1d1 d8e7 e1g1 c8g4 h2h3 g4f3 e2f3 e7e6 h4f6 e6f6 f3f6 g7f6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 3, 2, 1, 1, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3, 4], + [7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 3, 2, 2, 2, 2, 2, 3, 4, 3, 2, 1, 1, 1, 2, 3, 4, 3, 2, 1, 0, 1, 2, 3], + [7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 5, 4, 3, 3, 3, 3, 3, 3, 5, 4, 3, 2, 2, 2, 2, 2, 5, 4, 3, 2, 1, 1, 1, 2, 5, 4, 3, 2, 1, 0, 1, 2], + [7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 5, 4, 4, 4, 4, 4, 4, 6, 5, 4, 3, 3, 3, 3, 3, 6, 5, 4, 3, 2, 2, 2, 2, 6, 5, 4, 3, 2, 1, 1, 1, 6, 5, 4, 3, 2, 1, 0, 1], + [7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6, 6, 7, 6, 5, 5, 5, 5, 5, 5, 7, 6, 5, 4, 4, 4, 4, 4, 7, 6, 5, 4, 3, 3, 3, 3, 7, 6, 5, 4, 3, 2, 2, 2, 7, 6, 5, 4, 3, 2, 1, 1, 7, 6, 5, 4, 3, 2, 1, 0] + ]; } #pragma warning restore IDE0055 diff --git a/src/Lynx/Model/Position.cs b/src/Lynx/Model/Position.cs index f79c72b36..ec437070f 100644 --- a/src/Lynx/Model/Position.cs +++ b/src/Lynx/Model/Position.cs @@ -911,9 +911,9 @@ private int PawnAdditionalEvaluation(int bucket, int squareIndex, int pieceIndex rank = 7 - rank; } - var friendlyKingDistance = Utils.ChebyshevDistance(sameSideKingSquare, squareIndex); + var friendlyKingDistance = Constants.ChebyshevDistance[squareIndex][sameSideKingSquare]; - var enemyKingDistance = Utils.ChebyshevDistance(oppositeSideKingSquare, squareIndex); + var enemyKingDistance = Constants.ChebyshevDistance[squareIndex][oppositeSideKingSquare]; packedBonus += PassedPawnBonus[bucket][rank] + FriendlyKingDistanceToPassedPawnBonus[friendlyKingDistance] diff --git a/src/Lynx/Utils.cs b/src/Lynx/Utils.cs index d09df93d5..fb82ba943 100644 --- a/src/Lynx/Utils.cs +++ b/src/Lynx/Utils.cs @@ -214,21 +214,6 @@ public static short UnpackEG(int packed) return (short)((packed + 0x8000) >> 16); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int ChebyshevDistance(BoardSquare square1, BoardSquare square2) => - ChebyshevDistance((int)square1, (int)square2); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int ChebyshevDistance(int square1, int square2) - { - var xDelta = Math.Abs(Constants.File[square1] - Constants.File[square2]); - var yDelta = Math.Abs(Constants.Rank[square1] - Constants.Rank[square2]); - - return xDelta >= yDelta - ? xDelta - : yDelta; - } - [Conditional("DEBUG")] private static void GuardAgainstSideBoth(int side) { diff --git a/tests/Lynx.Test/Model/PositionTest.cs b/tests/Lynx.Test/Model/PositionTest.cs index dd444fc61..4f07c12b1 100644 --- a/tests/Lynx.Test/Model/PositionTest.cs +++ b/tests/Lynx.Test/Model/PositionTest.cs @@ -425,8 +425,8 @@ public void StaticEvaluation_PassedPawnBonus(string fen, BoardSquare square) rank = 7 - rank; } - var whiteKingDistance = ChebyshevDistance((int)square, position.PieceBitBoards[(int)Piece.K].GetLS1BIndex()); - var blackKingDistance = ChebyshevDistance((int)square, position.PieceBitBoards[(int)Piece.k].GetLS1BIndex()); + var whiteKingDistance = Constants.ChebyshevDistance[(int)square][position.PieceBitBoards[(int)Piece.K].GetLS1BIndex()]; + var blackKingDistance = Constants.ChebyshevDistance[(int)square][position.PieceBitBoards[(int)Piece.k].GetLS1BIndex()]; var friendlyKingDistance = position.Side == Side.White ? whiteKingDistance diff --git a/tests/Lynx.Test/UtilsTest.cs b/tests/Lynx.Test/UtilsTest.cs index 31b403b53..3b45f59d8 100644 --- a/tests/Lynx.Test/UtilsTest.cs +++ b/tests/Lynx.Test/UtilsTest.cs @@ -122,6 +122,6 @@ public void LongCastleRookSourceSquare(Side sideToMove, int expectedRookSquare) [TestCase(BoardSquare.h8, BoardSquare.a1, 7)] public void ChebyshevDistance(BoardSquare square1, BoardSquare square2, int expectedDistance) { - Assert.AreEqual(expectedDistance, Utils.ChebyshevDistance(square1, square2)); + Assert.AreEqual(expectedDistance, Constants.ChebyshevDistance[(int)square1][(int)square2]); } }