lynx-chess / Lynx

Chess Engine, written in C#
https://lichess.org/@/Lynx_BOT
MIT License
39 stars 3 forks source link

⚡ Replace Chebyshev distance calculation with lookup table (double array) #957

Closed eduherminio closed 2 weeks ago

eduherminio commented 2 weeks ago

Microbenchmarks give the lookup table as a clear winner, but reality seems to be different (as kinda usual):

Single array, [-5,0]

Score of Lynx-perf-chebyshevdistance-lookup-3702-win-x64 vs Lynx 3695 - main: 6232 - 6406 - 9792  [0.496] 22430
...      Lynx-perf-chebyshevdistance-lookup-3702-win-x64 playing White: 4648 - 1654 - 4914  [0.633] 11216
...      Lynx-perf-chebyshevdistance-lookup-3702-win-x64 playing Black: 1584 - 4752 - 4878  [0.359] 11214
...      White vs Black: 9400 - 3238 - 9792  [0.637] 22430
Elo difference: -2.7 +/- 3.4, LOS: 6.1 %, DrawRatio: 43.7 %
SPRT: llr -0.322 (-11.1%), lbound -2.25, ubound 2.89

Jagged array, [-3,1]

Score of Lynx-perf-chebyshevdistance-lookup-3718-win-x64 vs Lynx 3713 - main: 8119 - 8062 - 12774  [0.501] 28955
...      Lynx-perf-chebyshevdistance-lookup-3718-win-x64 playing White: 6031 - 2102 - 6345  [0.636] 14478
...      Lynx-perf-chebyshevdistance-lookup-3718-win-x64 playing Black: 2088 - 5960 - 6429  [0.366] 14477
...      White vs Black: 11991 - 4190 - 12774  [0.635] 28955
Elo difference: 0.7 +/- 3.0, LOS: 67.3 %, DrawRatio: 44.1 %
SPRT: llr 2.89 (100.0%), lbound -2.25, ubound 2.89 - H1 was accepted