X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=8b997b6056b99e8a55208fb980bd8312849cbca6;hp=6664742e5641c47386e6b6dff7d67995987340ce;hb=4d647428d8f6b02a404e6b7fda5dbbf17090f271;hpb=12ef8f71a2822f91e844e26d352d5fc27ac9559f diff --git a/src/pawns.cpp b/src/pawns.cpp index 6664742e..8b997b60 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -116,22 +116,10 @@ namespace { phalanx = neighbours & rank_bb(s); supported = neighbours & rank_bb(s - Up); - // A pawn is backward when it is behind all pawns of the same color on the - // adjacent files and cannot be safely advanced. - if (!neighbours || lever || relative_rank(Us, s) >= RANK_5) - backward = false; - else - { - // Find the backmost rank with neighbours or stoppers - b = rank_bb(backmost_sq(Us, neighbours | stoppers)); - - // The pawn is backward when it cannot safely progress to that rank: - // either there is a stopper in the way on this rank, or there is a - // stopper on adjacent file which controls the way to that rank. - backward = (b | shift(b & adjacent_files_bb(f))) & stoppers; - - assert(!(backward && (forward_ranks_bb(Them, s + Up) & neighbours))); - } + // A pawn is backward when it is behind all pawns of the same color + // on the adjacent files and cannot be safely advanced. + backward = !(ourPawns & pawn_attack_span(Them, s + Up)) + && (stoppers & (leverPush | (s + Up))); // Passed pawns will be properly scored in evaluation because we need // full attack info to evaluate them. Include also not passed pawns @@ -179,7 +167,7 @@ namespace Pawns { void init() { - static constexpr int Seed[RANK_NB] = { 0, 13, 24, 18, 76, 100, 175, 330 }; + static constexpr int Seed[RANK_NB] = { 0, 13, 24, 18, 65, 100, 175, 330 }; for (int opposed = 0; opposed <= 1; ++opposed) for (int phalanx = 0; phalanx <= 1; ++phalanx) @@ -226,8 +214,8 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { enum { Unopposed, BlockedByPawn, Unblocked }; constexpr Color Them = (Us == WHITE ? BLACK : WHITE); - constexpr Direction Up = (Us == WHITE ? NORTH : SOUTH); - constexpr Bitboard BlockRanks = (Us == WHITE ? Rank2BB | Rank3BB : Rank7BB | Rank6BB); + constexpr Direction Down = (Us == WHITE ? SOUTH : NORTH); + constexpr Bitboard BlockRanks = (Us == WHITE ? Rank1BB | Rank2BB : Rank8BB | Rank7BB); Bitboard b = pos.pieces(PAWN) & (forward_ranks_bb(Us, ksq) | rank_bb(ksq)); Bitboard ourPawns = b & pos.pieces(Us); @@ -235,7 +223,7 @@ Value Entry::evaluate_shelter(const Position& pos, Square ksq) { Value safety = (ourPawns & file_bb(ksq)) ? Value(5) : Value(-5); - if ((theirPawns & (FileABB | FileHBB) & BlockRanks) & (ksq + Up)) + if (shift(theirPawns) & (FileABB | FileHBB) & BlockRanks & ksq) safety += 374; File center = std::max(FILE_B, std::min(FILE_G, file_of(ksq)));