public static bool isMate(King king, ChessPiece[,] positions) { for (int i = 0, rank = king.Rank - 1; i < 3; i++, rank++) { for (int j = 0, file = king.File - 1; j < 3; j++, file++) { if (rank < 0 || rank > 7 || file < 0 || file > 7 || rank == file) continue; if (king. isValidMove (rank, file, positions, ChessBoardConstants. MOVE_EXCHANGE)) return false; } } return true; }