X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=ea0dffc72ba34c738537cedd18f6e3797540407c;hp=7cc71ca6ae8606df53fcc89c9e3ce5333fbdf6cf;hb=d2274e609c28e46a24deee55b05684197d369976;hpb=d0f09de2d24f53ccab09928eb776423c813d6580 diff --git a/src/pawns.cpp b/src/pawns.cpp index 7cc71ca6..ea0dffc7 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -32,9 +32,9 @@ namespace { #define S(mg, eg) make_score(mg, eg) // Pawn penalties - constexpr Score Isolated = S( 5, 15); - constexpr Score Backward = S( 9, 24); - constexpr Score Doubled = S(11, 56); + constexpr Score Backward = S( 9, 24); + constexpr Score Doubled = S(11, 56); + constexpr Score Isolated = S( 5, 15); // Connected pawn bonus by opposed, phalanx, #support and rank Score Connected[2][2][3][RANK_NB]; @@ -58,10 +58,6 @@ namespace { { V(-10), V(-14), V( 90), V(15), V( 2), V( -7), V(-16) } }; - // Danger of blocked enemy pawns storming our king, by rank - constexpr Value BlockedStorm[RANK_NB] = - { V(0), V(0), V(66), V(6), V(5), V(1), V(15) }; - #undef S #undef V @@ -225,7 +221,7 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { int d = std::min(f, ~f); safety += ShelterStrength[d][ourRank]; - safety -= (ourRank && (ourRank == theirRank - 1)) ? BlockedStorm[theirRank] + safety -= (ourRank && (ourRank == theirRank - 1)) ? 66 * (theirRank == RANK_3) : UnblockedStorm[d][theirRank]; } @@ -237,30 +233,31 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { /// when king square changes, which is about 20% of total king_safety() calls. template -Score Entry::do_king_safety(const Position& pos, Square ksq) { +Score Entry::do_king_safety(const Position& pos) { + Square ksq = pos.square(Us); kingSquares[Us] = ksq; castlingRights[Us] = pos.can_castle(Us); int minKingPawnDistance = 0; Bitboard pawns = pos.pieces(Us, PAWN); if (pawns) - while (!(DistanceRingBB[ksq][minKingPawnDistance++] & pawns)) {} + while (!(DistanceRingBB[ksq][++minKingPawnDistance] & pawns)) {} Value bonus = evaluate_shelter(pos, ksq); // If we can castle use the bonus after the castling if it is bigger - if (pos.can_castle(MakeCastling::right)) + if (pos.can_castle(Us | KING_SIDE)) bonus = std::max(bonus, evaluate_shelter(pos, relative_square(Us, SQ_G1))); - if (pos.can_castle(MakeCastling::right)) + if (pos.can_castle(Us | QUEEN_SIDE)) bonus = std::max(bonus, evaluate_shelter(pos, relative_square(Us, SQ_C1))); return make_score(bonus, -16 * minKingPawnDistance); } // Explicit template instantiation -template Score Entry::do_king_safety(const Position& pos, Square ksq); -template Score Entry::do_king_safety(const Position& pos, Square ksq); +template Score Entry::do_king_safety(const Position& pos); +template Score Entry::do_king_safety(const Position& pos); } // namespace Pawns