xeenoon / ChessApp

0 stars 0 forks source link

Bugs in move generator #13

Closed xeenoon closed 2 years ago

xeenoon commented 2 years ago

Pin/Attack issues

image

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

image 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 image

image

This fixes the king moves problem, however: image

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

image

After white moves d4

image

En-passant here is not allowed as it opens up an attack from the rook

image

The pin checker doesn't detect this, because it sees two pieces on the same xray, meaning that there is no pin.

image

This works usually in positions like this: 8/8/8/2b5/k7/4N3/5N2/6K1 w - - 0 1 image

Both knights can move without putting the king in check