M Winther wrote on Thu, Nov 15, 2012 04:54 PM UTC:
If you want to know whether your king is threatened, you'll have to search out where it is, and then check this square with the "attacked?" command.
But if you only need to know whether a certain enemy piece is attacking your king, you could perhaps use the same principle as I use in Coordinator Chess, for instance. I have added a "king gaze" move to the king's definition, at a lower priority than standard moves, so the king never performs them. Other pieces can then check if the king "sees" an enemy piece on the diagonal or the orthogonal, or the knight jump.
M. Winther
out where it is, and then check this square with the "attacked?" command.
But if you only need to know whether a certain enemy piece is attacking your
king, you could perhaps use the same principle as I use in
Coordinator Chess, for instance. I have added a "king gaze" move to the king's
definition, at a lower priority than standard moves, so the king never
performs them. Other pieces can then check if the king "sees" an enemy piece on the
diagonal or the orthogonal, or the knight jump.
M. Winther