I have been studying the Java version of OliThink (v5.3.2) to better understand bitboard-based move generation. When doing some perft testing, I discovered a position ("5K2/8/1Q6/2N5/8/1p2k3/8/8 w - - 0 1") where OliThink (& OliPerft) reported 197,013,057 moves at depth 7, but frcperft and Stockfish 4 both returned 197,013,195. I narrowed this down to "7K/8/1Q6/2N5/8/4k3/8/q7 w - - 2 4" for which OliThink reported only 2 valid moves for White, completely ignoring the legal Queen moves to b2 or f6.
I was able to further track this down to a single line of code in the
getDir method:
Code: Select all
return (byte)(((f - t) % 7) != 0 ? 32 : 64);
This returns an incorrect result for the edge case where f = 63 and t = 0; to fix the bug, change the same line to:
Code: Select all
return (byte) ((((f - t) % 9) == 0) ? 32 : 64)
Based on a cursory examination, it looks like the native versions of OliThink and OliPerft have the same flaw and can be fixed in exactly the same manner. Nonetheless, I commend Oliver Brausch for his hard work on OliPerft & OliThink, and thank him for making the source code available to the rest of us.
Cheers!
Humble Programmer
,,,^..^,,,