which leaves black to play gives d8d2 as a valid move. However, black is in check from the queen on a4, and d8d2 doesn't evade it. After a bit of digging the problem is the else here in Board::Init():
Checks = 0;
if (BitBoards[KW] & UnsafeForWhite)
Checks |= CHECK_WHITE;
else if (BitBoards[KB] & UnsafeForBlack)
Checks |= CHECK_BLACK;
Although black's move is illegal, it's one that puts the white king immediately in check, so the first condition above is met but not the second. And just like that, black isn't in check as far as the game is concerned :)
Removing the else from the above code fixes the perft tests (found at startpos, depth 6 initially) and stops a few oddities.
This position:
position startpos moves a2a3 d7d5 c2c4 d5c4 d1a4
which leaves black to play gives
d8d2
as a valid move. However, black is in check from the queen ona4
, andd8d2
doesn't evade it. After a bit of digging the problem is theelse
here inBoard::Init()
:Although black's move is illegal, it's one that puts the white king immediately in check, so the first condition above is met but not the second. And just like that, black isn't in check as far as the game is concerned :)
Removing the
else
from the above code fixes the perft tests (found at startpos, depth 6 initially) and stops a few oddities.