X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fevaluate.cpp;h=a9c4c4e787fc69f0d1530f5a1a8b3cca15dd8e42;hb=f99cb3dc27719021e126690b7fd5aa5f43663ed8;hp=5b1f4f40ce493c0546a8944c7febb8cf717b5048;hpb=ecd07e51d0f03ccd3e41e5634518b299989254dd;p=stockfish diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 5b1f4f40..a9c4c4e7 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -83,6 +83,8 @@ namespace { // king is on g8 and there's a white knight on g5, this knight adds // 2 to kingAdjacentZoneAttacksCount[BLACK]. int kingAdjacentZoneAttacksCount[COLOR_NB]; + + Bitboard pinnedPieces[COLOR_NB]; }; // Evaluation grain size, must be a power of 2 @@ -423,6 +425,8 @@ Value do_evaluate(const Position& pos) { const Color Them = (Us == WHITE ? BLACK : WHITE); const Square Down = (Us == WHITE ? DELTA_S : DELTA_N); + ei.pinnedPieces[Us] = pos.pinned_pieces(Us); + Bitboard b = ei.attackedBy[Them][KING] = pos.attacks_from(pos.king_square(Them)); ei.attackedBy[Us][PAWN] = ei.pi->pawn_attacks(Us); @@ -487,6 +491,9 @@ Value do_evaluate(const Position& pos) { : Piece == ROOK ? attacks_bb< ROOK>(s, pos.pieces() ^ pos.pieces(Us, ROOK, QUEEN)) : pos.attacks_from(s); + if (ei.pinnedPieces[Us] & s) + b &= LineBB[pos.king_square(Us)][s]; + ei.attackedBy[Us][Piece] |= b; if (b & ei.kingRing[Them]) @@ -562,7 +569,7 @@ Value do_evaluate(const Position& pos) { Square ksq = pos.king_square(Us); // Penalize rooks which are trapped inside a king. Penalize more if - // king has lost right to castle. + // king has lost castling availability. if ( ((file_of(ksq) < FILE_E) == (file_of(s) < file_of(ksq))) && (rank_of(ksq) == rank_of(s) || relative_rank(Us, ksq) == RANK_1) && !ei.pi->semiopen_on_side(Us, file_of(ksq), file_of(ksq) < FILE_E))