X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fevaluate.cpp;h=0f19783a2f1fbc017511bc7a12908ab8f1d5d059;hb=eddfd46a1016c544cc0f18600677fe121f3cbbff;hp=0bf64631c9d4a8686554619b43eb813c4c94de91;hpb=cff9ff21985edcf1d15e7df6c0e0039f550706ad;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 0bf64631..0f19783a 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -207,7 +207,7 @@ namespace { ((1ULL << SQ_A8) | (1ULL << SQ_H8)) }; - // The SpaceMask[color] contains the area of the board which is consdered + // The SpaceMask[color] contains the area of the board which is considered // by the space evaluation. In the middle game, each side is given a bonus // based on how many squares inside this area are safe and available for // friendly minor pieces. @@ -550,19 +550,19 @@ namespace { ei.kingAdjacentZoneAttacksCount[Us] += count_1s_max_15(bb); } - // The squares occupied by enemy pieces will be counted two times instead - // of one. The shift (almost) guarantees that intersection with b is zero - // so when we 'or' the two bitboards togheter and count we get the correct - // sum of '1' in b and attacked bitboards. - Bitboard attacked = Us == WHITE ? ((b & pos.pieces_of_color(Them)) >> 1) - : ((b & pos.pieces_of_color(Them)) << 1); - // Remove squares protected by enemy pawns or occupied by our pieces b &= ~(ei.attackedBy[Them][PAWN] | pos.pieces_of_color(Us)); + // The squares occupied by enemy pieces (not defended by pawns) will be + // counted two times instead of one. The shift (almost) guarantees that + // intersection of the shifted value with b is zero so that after or-ing + // the count of 1s bits is increased by the number of affected squares. + b |= Us == WHITE ? ((b & pos.pieces_of_color(Them)) >> 1) + : ((b & pos.pieces_of_color(Them)) << 1); + // Mobility - int mob = (Piece != QUEEN ? count_1s_max_15(b | attacked) - : count_1s(b | attacked)); + int mob = (Piece != QUEEN ? count_1s_max_15(b) + : count_1s(b)); if (mob > lastIndex[Piece]) mob = lastIndex[Piece];