Author: KarinsDad
Date: 14:37:45 06/13/99
Go up one level in this thread
On June 13, 1999 at 16:33:18, Michel Langeveld wrote: >Thank you for your description. > >Do you also noticed this position(Black to move): > >White: King=d5, pawn=b5 >Black: King=d7, rook=a5, pawn=c7 > >after the move c7-c5 > >The pawn cannot capture en passant. > >How do you handle this? Yikes!!! I hadn't even considered that. Bug alert! Bug alert! Bug alert! Thanks for pointing this out! Easy enough to resolve though, just a little more coding and a little more processing, but it is rare, so not a biggy. When the en-passant bit is set, the special cases must be handled. There are multiple possibilities here: a) b/q p K (any of 4 directions) diagonally. b) b/q P K (any of 2 directions) diagonally. c) r/q p P K and r/q P p K (any of 2 directions) horizontally. There are no vertical cases since the taking pawn will still prevent check. a) can be handled by seeing if the next piece found on the diagonal is the en-passant pawn (and the piece after that is an opposite colored bishop or queen). If so, then it cannot be taken and the pin byte of the pawns that are capable of taking it are adjusted accordingly. A quick check here is to see if row + column of the en-passant pawn = row + column of the king OR if row - column of the en-passant pawn = row - column of the king (code modified to have no subtractions of course). If neither of these hit, then you can ignore en-passant checking for the diagonal directions. b) is the same as a), but you check for your own pawn moving instead of the opponent's pawn being taken. Note: case b) will be handled automatically by the normal bitboard pin code. c) is a little trickier. There would be 4 different types of bitboard comparisons and each would be a little lengthier than the normal bitboard comparisons . However, there is the advantage here that these checks would only have to be done if the king is on it's 5th rank. Otherwise, you can ignore en-passant checking for the horizontal direction. And, of course, if a) or c) is handled, then that direction is taken care of, so it does not have to be handled in the normal pin code. Since this is so rare, it could also be handled in the normal way of checking the move for putting the king in check after the fact. But, I would not bother. I would just have 2 sets of similar code in my move generator, one for en-passant and one for no en-passant. Thanks again! :) KarinsDad :) PS. This should cover it since there are no other cases of one piece taking another piece and the taking piece does not end up on the same square.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.