X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fpawns.cpp;h=aa41c2cd8150b6baf86809d8e43832bacd7f2e25;hp=1d8b082ed449cb55281054b156721ba79deeaf42;hb=564ed5b38cb2b99e8770ed1c0ceee7c3e769eb0a;hpb=76bed11f7b79d939c250c02d73d0c1e2628e7a17 diff --git a/src/pawns.cpp b/src/pawns.cpp index 1d8b082e..aa41c2cd 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -193,12 +193,16 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) { Value mgValue[2] = {Value(0), Value(0)}; Value egValue[2] = {Value(0), Value(0)}; + // Calculate pawn attacks + pi->pawnAttacks[WHITE] = ((pos.pieces(PAWN, WHITE) << 9) & ~FileABB) | ((pos.pieces(PAWN, WHITE) << 7) & ~FileHBB); + pi->pawnAttacks[BLACK] = ((pos.pieces(PAWN, BLACK) >> 7) & ~FileABB) | ((pos.pieces(PAWN, BLACK) >> 9) & ~FileHBB); + // Loop through the pawns for both colors for (Color us = WHITE; us <= BLACK; us++) { Color them = opposite_color(us); - Bitboard ourPawns = pos.pieces(us); - Bitboard theirPawns = pos.pieces(them); + Bitboard ourPawns = pos.pieces(PAWN, us); + Bitboard theirPawns = pos.pieces(PAWN, them); Bitboard pawns = ourPawns; // Initialize pawn storm scores by giving bonuses for open files @@ -299,12 +303,11 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) { // it cannot be backward. If can capture an enemy pawn or if // there are friendly pawns behind on neighboring files it cannot // be backward either. + bool backward; - if ( passed - || isolated - || chain - || (pos.pawn_attacks(us, s) & theirPawns) - || (ourPawns & behind_bb(us, r) & neighboring_files_bb(f))) + if ( (passed | isolated | chain) + || (ourPawns & behind_bb(us, r) & neighboring_files_bb(f)) + || (pos.attacks_from(s, us) & theirPawns)) backward = false; else { @@ -312,7 +315,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) { // pawn on neighboring files. We now check whether the pawn is // backward by looking in the forward direction on the neighboring // files, and seeing whether we meet a friendly or an enemy pawn first. - Bitboard b = pos.pawn_attacks(us, s); + Bitboard b = pos.attacks_from(s, us); if (us == WHITE) { for ( ; !(b & (ourPawns | theirPawns)); b <<= 8); @@ -392,7 +395,7 @@ PawnInfo* PawnInfoTable::get_pawn_info(const Position& pos) { int PawnInfo::updateShelter(const Position& pos, Color c, Square ksq) { unsigned shelter = 0; - Bitboard pawns = pos.pieces(c) & this_and_neighboring_files_bb(ksq); + Bitboard pawns = pos.pieces(PAWN, c) & this_and_neighboring_files_bb(ksq); unsigned r = ksq & (7 << 3); for (int i = 1, k = (c ? -8 : 8); i < 4; i++) {