isAttacked method
Checks if square
is attacked by player
.
Works by generating all legal moves for the other player, and therefore is slow.
Implementation
bool isAttacked(int square, int player) {
List<Move> attacks =
generatePlayerMoves(player, MoveGenParams.squareAttacks(square));
return attacks.isNotEmpty;
}