diff --git a/src/benchmark.cpp b/src/benchmark.cpp index 4e266db89..03bf10ae1 100644 --- a/src/benchmark.cpp +++ b/src/benchmark.cpp @@ -64,6 +64,7 @@ const std::vector Defaults = { "r3k2r/3nnpbp/q2pp1p1/p7/Pp1PPPP1/4BNN1/1P5P/R2Q1RK1 w kq - 0 16", "3Qb1k1/1r2ppb1/pN1n2q1/Pp1Pp1Pr/4P2p/4BP2/4B1R1/1R5K b - - 11 40", "4k3/3q1r2/1N2r1b1/3ppN2/2nPP3/1B1R2n1/2R1Q3/3K4 w - - 5 1", + "1r6/1P4bk/3qr1p1/N6p/3pp2P/6R1/3Q1PP1/1R4K1 w - - 1 42", // Positions with high numbers of changed threats "k7/2n1n3/1nbNbn2/2NbRBn1/1nbRQR2/2NBRBN1/3N1N2/7K w - - 0 1", diff --git a/src/position.cpp b/src/position.cpp index 3b7b197ff..daadf59ec 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -1131,7 +1131,9 @@ void Position::update_piece_threats(Piece pc, if constexpr (PutPiece) { dts->threatenedSqs |= threatened; - dts->threateningSqs |= s; + // A bit may only be set if that square actually produces a threat, so we + // must guard setting the square accordingly + dts->threateningSqs |= Bitboard(bool(threatened)) << s; } DirtyThreat dt_template{pc, NO_PIECE, s, Square(0), PutPiece}; @@ -1142,7 +1144,7 @@ void Position::update_piece_threats(Piece pc, if constexpr (PutPiece) { - dts->threatenedSqs |= s; + dts->threatenedSqs |= Bitboard(bool(all_attackers)) << s; // same as above dts->threateningSqs |= all_attackers; }