- Bitboard pinned = pos.pinned_pieces(c);
-
- // Knights
- for (int i = 0; i < pos.piece_count(c, KNIGHT); i++)
- evaluate_knight(pos, pos.piece_list(c, KNIGHT, i), c, pinned, ei);
-
- // Bishops
- for (int i = 0; i < pos.piece_count(c, BISHOP); i++)
- evaluate_bishop(pos, pos.piece_list(c, BISHOP, i), c, pinned, ei);
-
- // Rooks
- for (int i = 0; i < pos.piece_count(c, ROOK); i++)
- evaluate_rook(pos, pos.piece_list(c, ROOK, i), c, pinned, ei);
-
- // Queens
- for(int i = 0; i < pos.piece_count(c, QUEEN); i++)
- evaluate_queen(pos, pos.piece_list(c, QUEEN, i), c, pinned, ei);
-
- // Special pattern: trapped bishops on a7/h7/a2/h2
- Bitboard b = pos.bishops(c) & MaskA7H7[c];
- while (b)
- {
- Square s = pop_1st_bit(&b);
- evaluate_trapped_bishop_a7h7(pos, s, c, ei);
- }
-
- // Special pattern: trapped bishops on a1/h1/a8/h8 in Chess960:
- if (Chess960)
- {
- b = pos.bishops(c) & MaskA1H1[c];
- while (b)
- {
- Square s = pop_1st_bit(&b);
- evaluate_trapped_bishop_a1h1(pos, s, c, ei);
- }
- }
-
- // Sum up all attacked squares
- ei.attackedBy[c][0] = ei.attackedBy[c][PAWN] | ei.attackedBy[c][KNIGHT]
- | ei.attackedBy[c][BISHOP] | ei.attackedBy[c][ROOK]
- | ei.attackedBy[c][QUEEN] | ei.attackedBy[c][KING];
+ evaluate_pieces<KNIGHT>(pos, c, ei);
+ evaluate_pieces<BISHOP>(pos, c, ei);
+ evaluate_pieces<ROOK>(pos, c, ei);
+ evaluate_pieces<QUEEN>(pos, c, ei);
+
+ // Sum up all attacked squares
+ ei.attackedBy[c][0] = ei.attackedBy[c][PAWN] | ei.attackedBy[c][KNIGHT]
+ | ei.attackedBy[c][BISHOP] | ei.attackedBy[c][ROOK]
+ | ei.attackedBy[c][QUEEN] | ei.attackedBy[c][KING];