X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=34c25959ab957e300a4857056f4ca5f23bc4efa2;hp=0ccfe809a1dcfb806406887098a62a6945dbee77;hb=66c5835080c8c1dab6bf203d2b6d9db6ab9439cc;hpb=ea5af9b8c0822ded58d587a89c9b43f163552c1d diff --git a/src/pawns.cpp b/src/pawns.cpp index 0ccfe809..34c25959 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -94,8 +94,8 @@ namespace { }; // Pawn storm open file bonuses by file - const int16_t KStormOpenFileBonus[8] = { 31, 31, 18, 0, 0, 0, 0, 0 }; - const int16_t QStormOpenFileBonus[8] = { 0, 0, 0, 0, 0, 26, 42, 26 }; + const int16_t QStormOpenFileBonus[8] = { 31, 31, 18, 0, 0, 0, 0, 0 }; + const int16_t KStormOpenFileBonus[8] = { 0, 0, 0, 0, 0, 26, 42, 26 }; // Pawn storm lever bonuses by file const int StormLeverBonus[8] = { -8, -8, -13, 0, 0, -13, -8, -8 }; @@ -148,7 +148,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) const { assert(pos.is_ok()); Key key = pos.get_pawn_key(); - int index = int(key & (size - 1)); + unsigned index = unsigned(key & (size - 1)); PawnInfo* pi = entries + index; // If pi->key matches the position's pawn hash key, it means that we @@ -231,7 +231,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, // there are friendly pawns behind on neighboring files it cannot // be backward either. if ( (passed | isolated | chain) - || (ourPawns & outpost_mask(opposite_color(Us), s)) + || (ourPawns & attack_span_mask(opposite_color(Us), s)) || (pos.attacks_from(s, Us) & theirPawns)) backward = false; else @@ -252,12 +252,12 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, backward = (b | (Us == WHITE ? b << 8 : b >> 8)) & theirPawns; } + assert(passed | opposed | (attack_span_mask(Us, s) & theirPawns)); + // Test for candidate passed pawn - candidate = !passed - && !opposed - && ( count_1s_max_15(neighboring_files_bb(f) & (behind_bb(Us, r) | rank_bb(r)) & ourPawns) - - count_1s_max_15(neighboring_files_bb(f) & in_front_bb(Us, r) & theirPawns) - >= 0); + candidate = !(opposed | passed) + && (b = attack_span_mask(opposite_color(Us), s + pawn_push(Us)) & ourPawns) != EmptyBoardBB + && count_1s_max_15(b) >= count_1s_max_15(attack_span_mask(Us, s) & theirPawns); // In order to prevent doubled passed pawns from receiving a too big // bonus, only the frontmost passed pawn on each file is considered as @@ -274,7 +274,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, if (isolated) { value -= IsolatedPawnPenalty[f]; - if (!(theirPawns & file_bb(f))) + if (!opposed) value -= IsolatedPawnPenalty[f] / 2; } if (doubled) @@ -283,7 +283,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, if (backward) { value -= BackwardPawnPenalty[f]; - if (!(theirPawns & file_bb(f))) + if (!opposed) value -= BackwardPawnPenalty[f] / 2; } if (chain) @@ -309,7 +309,7 @@ int PawnInfoTable::evaluate_pawn_storm(Square s, Rank r, File f, Bitboard theirP const int K = (Side == KingSide ? 2 : 4); const File RookFile = (Side == KingSide ? FILE_H : FILE_A); - Bitboard b = outpost_mask(Us, s) & theirPawns & StormFilesBB; + Bitboard b = attack_span_mask(Us, s) & theirPawns & StormFilesBB; int bonus = 0; while (b)