Castling
To determine if your king can still castle in chess, you need to check the following conditions:
- King and Rook’s Initial Movement:
• The king and the rook involved in castling must not have moved at any point in the game. If either has moved, even if they return to their original squares, castling is no longer allowed.
- King’s Current Position:
• The king must still be on its original square (e1 for White, e8 for Black).
- Rook’s Current Position:
• The rook involved in castling must be on its original square (a1 or h1 for White; a8 or h8 for Black).
- No Pieces Blocking the Path:
• All squares between the king and the rook must be unoccupied.
- Safe Path for the King:
• The king cannot move through or end up in a square that is under attack by an opponent’s piece. For example:
• The king cannot move from e1 to g1 (or c1) if f1 (or d1) is attacked.
• The destination square (g1 or c1) must not be attacked.
- No Check:
• The king cannot currently be in check.
If all these conditions are met, castling is still possible. Depending on which rook is involved, it is either kingside castling (short castling) or queenside castling (long castling).
en passant
To determine if your pawn can perform an en passant capture, the following conditions must be met:
- Opponent’s Pawn Double-Step Move:
• On the immediately preceding turn, your opponent must have moved a pawn forward two squares from its starting position. This means the pawn moved from the 2nd rank to the 4th rank (for White) or from the 7th rank to the 5th rank (for Black).
- Your Pawn’s Position:
• Your pawn must be on the same rank as the opponent’s pawn that just performed the double-step move, and it must be in an adjacent file. For example:
• If your opponent moves their pawn from e7 to e5, your pawn must be on d5 or f5 to capture en passant.
- Timing of the Capture:
• The en passant capture must occur immediately after your opponent’s double-step pawn move. If you make any other move, the opportunity to capture en passant is lost.
- Execution of the Move:
• To perform the en passant capture, move your pawn diagonally to the square the opponent’s pawn passed over (the square directly behind the opponent’s pawn). For example:
• If your opponent moves a pawn from e7 to e5, and your pawn is on d5, you capture en passant by moving your pawn to e6.
If all these conditions are satisfied, your pawn can legally perform the en passant capture.