A bug in the calculation of the most significant bit
caused undefined behavior in the king safety evaluation.
The fix significantly improves playing strength of the large-board version:
chess
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 100 W: 72 L: 15 D: 13
capablanca
LLR: 2.98 (-2.94,2.94) [-10.00,5.00]
Total: 82 W: 62 L: 8 D: 12
shogi
LLR: 2.97 (-2.94,2.94) [-10.00,5.00]
Total: 256 W: 157 L: 92 D: 7
No functional change for normal version.
assert(b);
#ifdef LARGEBOARDS
if (b >> 64)
- return Square(SQUARE_BIT_MASK ^ (__builtin_clzll(b >> 64) + 64));
-#endif
+ return Square(SQUARE_BIT_MASK ^ __builtin_clzll(b >> 64));
+ return Square(SQUARE_BIT_MASK ^ (__builtin_clzll(b) + 64));
+#else
return Square(SQUARE_BIT_MASK ^ __builtin_clzll(b));
+#endif
}
#elif defined(_MSC_VER) // MSVC