efficient in_check routine
Loomis Philanthrope wrote:
Hi all,
I am trying to write an efficient routine to determine whether the king
is in check. Any ideas you know of are welcome.
I am using the 0x88 board representation. My current method is to loop
over the opponents pieces and use the difference between the king square
the the piece square as an index into an array that tells me if the
piece could attack the king from that square. Then for sliding pieces I
traverse the direction of attack to see if all the squares between are
empty. Then I check the two squares where pawns could attack from to see
if they're occupied by opponents pawns.
Is there a more efficient way to do this?
Remember what the last move was. Determine whether that move could have
put the king in check. No need to look at all pieces.
--
GCP
|