isAttacked method

bool isAttacked(
  1. int square,
  2. int player
)

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;
}