-
Notifications
You must be signed in to change notification settings - Fork 335
Open
Description
When you check the legality of an en passant capture, except for this capture opening a horizontal check, you also have this interesting condition, which I don't understand why it's necessary.
As I understand the code, it seems to check that there's no friendly king behind the friendly pawn and looks like a rule "En passant cannot be used to avoid check", although this rule does not exist...
// check if
enemy pawn is controlling this square (can't use pawn attack bitboard, because pawn has been captured)
for (int i = 0; i < 2; i++) {
// Check if square exists diagonal to friendly king from which enemy pawn could be attacking it
if (numSquaresToEdge[friendlyKingSquare][pawnAttackDirections[friendlyColourIndex][i]] > 0) {
// move in direction friendly pawns attack to get square from which enemy pawn would attack
int piece = board.Square[friendlyKingSquare + directionOffsets[pawnAttackDirections[friendlyColourIndex][i]]];
if (piece == (Piece.Pawn | opponentColour)) // is enemy pawn
{
return true;
}
}
}
Why is this condition necessary?
Metadata
Metadata
Assignees
Labels
No labels