X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=069c8d9401aa29127699235ee9e6cb872384d367;hp=f71e2a3970f8cbd520e8567ec7d6729126b05eb8;hb=55bd27b8f08a151128d7065fa2819aa3e9605299;hpb=9793fa1906cc204fc2a520ebb8dd3093f7fc7e40 diff --git a/src/pawns.cpp b/src/pawns.cpp index f71e2a39..069c8d94 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -240,12 +240,12 @@ Value PawnEntry::shelter_storm(const Position& pos, Square ksq) { { // Shelter penalty is higher for the pawn in front of the king b = ourPawns & FileBB[f]; - rkUs = b ? rank_of(Us == WHITE ? first_1(b) : ~last_1(b)) : RANK_1; + rkUs = b ? rank_of(Us == WHITE ? lsb(b) : ~msb(b)) : RANK_1; safety -= ShelterWeakness[f != kf][rkUs]; // Storm danger is smaller if enemy pawn is blocked b = theirPawns & FileBB[f]; - rkThem = b ? rank_of(Us == WHITE ? first_1(b) : ~last_1(b)) : RANK_1; + rkThem = b ? rank_of(Us == WHITE ? lsb(b) : ~msb(b)) : RANK_1; safety -= StormDanger[rkThem == rkUs + 1][rkThem]; } @@ -268,7 +268,7 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) { while (!(DistanceRingsBB[ksq][minKPdistance[Us]++] & pawns)) {} if (relative_rank(Us, ksq) > RANK_4) - return kingSafety[Us] = SCORE_ZERO; + return kingSafety[Us] = make_score(0, -16 * minKPdistance[Us]); Value bonus = shelter_storm(pos, ksq); @@ -279,7 +279,7 @@ Score PawnEntry::update_safety(const Position& pos, Square ksq) { if (pos.can_castle(make_castle_right(Us, QUEEN_SIDE))) bonus = std::max(bonus, shelter_storm(pos, relative_square(Us, SQ_C1))); - return kingSafety[Us] = make_score(bonus, 0); + return kingSafety[Us] = make_score(bonus, -16 * minKPdistance[Us]); } // Explicit template instantiation