Just finding attack rays & pin rays isn't enough for king movements. Take the following positions.
8/3kb3/8/8/8/8/1KPR4/8 b - - 0 1
With the black king included in the blockers ulong, it thinks that there is a legal move to move backwards, when in fact this would mean the king is attacked by the rook
This seems like a simple fix, however, if we change the code to NOT include the king in the blockers ulong
This fixes the king moves problem, however:
The square behind the king is now seen as a valid square to block the check
En-passant issue
4K3/8/8/8/k1p4R/8/3P4/8 w - - 0 1
After white moves d4
En-passant here is not allowed as it opens up an attack from the rook
The pin checker doesn't detect this, because it sees two pieces on the same xray, meaning that there is no pin.
This works usually in positions like this:
8/8/8/2b5/k7/4N3/5N2/6K1 w - - 0 1
Both knights can move without putting the king in check
Pin/Attack issues
Just finding attack rays & pin rays isn't enough for king movements. Take the following positions.
8/3kb3/8/8/8/8/1KPR4/8 b - - 0 1
With the black king included in the blockers ulong, it thinks that there is a legal move to move backwards, when in fact this would mean the king is attacked by the rook
This seems like a simple fix, however, if we change the code to NOT include the king in the blockers ulong
This fixes the king moves problem, however:
The square behind the king is now seen as a valid square to block the check
En-passant issue
4K3/8/8/8/k1p4R/8/3P4/8 w - - 0 1
After white moves d4
En-passant here is not allowed as it opens up an attack from the rook
The pin checker doesn't detect this, because it sees two pieces on the same xray, meaning that there is no pin.
This works usually in positions like this:
8/8/8/2b5/k7/4N3/5N2/6K1 w - - 0 1
Both knights can move without putting the king in check