/// when king square changes, which is about 20% of total king_safety() calls.
template<Color Us>
-Score Entry::do_king_safety(const Position& pos, Square ksq) {
+Score Entry::do_king_safety(const Position& pos) {
+ Square ksq = pos.square<KING>(Us);
kingSquares[Us] = ksq;
castlingRights[Us] = pos.can_castle(Us);
int minKingPawnDistance = 0;
Value bonus = evaluate_shelter<Us>(pos, ksq);
// If we can castle use the bonus after the castling if it is bigger
- if (pos.can_castle(MakeCastling<Us, KING_SIDE>::right))
+ if (pos.can_castle(Us | KING_SIDE))
bonus = std::max(bonus, evaluate_shelter<Us>(pos, relative_square(Us, SQ_G1)));
- if (pos.can_castle(MakeCastling<Us, QUEEN_SIDE>::right))
+ if (pos.can_castle(Us | QUEEN_SIDE))
bonus = std::max(bonus, evaluate_shelter<Us>(pos, relative_square(Us, SQ_C1)));
return make_score(bonus, -16 * minKingPawnDistance);
}
// Explicit template instantiation
-template Score Entry::do_king_safety<WHITE>(const Position& pos, Square ksq);
-template Score Entry::do_king_safety<BLACK>(const Position& pos, Square ksq);
+template Score Entry::do_king_safety<WHITE>(const Position& pos);
+template Score Entry::do_king_safety<BLACK>(const Position& pos);
} // namespace Pawns