Skip to content

Commit 35840a1

Browse files
authored
Merge pull request official-stockfish#481 from ianfab/zh_checks
Reintroduce bonus for checks by piece drops in crazyhouse
2 parents 8b03dc3 + 9f127ae commit 35840a1

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/evaluate.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,15 +1010,17 @@ namespace {
10101010
safe |= attackedBy[Us][KING];
10111011
#endif
10121012

1013+
// Defended by our queen or king only
1014+
Bitboard dqko = ~attackedBy2[Us] & (attackedBy[Us][QUEEN] | attackedBy[Us][KING]);
1015+
Bitboard dropSafe = (safe | (attackedBy[Them][ALL_PIECES] & dqko)) & ~pos.pieces(Us);
1016+
10131017
b1 = attacks_bb<ROOK >(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN));
10141018
b2 = attacks_bb<BISHOP>(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN));
10151019

10161020
// Enemy queen safe checks
1017-
if ((b1 | b2) & attackedBy[Them][QUEEN] & safe & ~attackedBy[Us][QUEEN])
1021+
if ((b1 | b2) & (h | attackedBy[Them][QUEEN]) & safe & ~attackedBy[Us][QUEEN])
10181022
kingDanger += QueenSafeCheck;
10191023

1020-
b1 &= attackedBy[Them][ROOK];
1021-
b2 &= attackedBy[Them][BISHOP];
10221024
#ifdef THREECHECK
10231025
if (pos.is_three_check() && pos.checks_given(Them))
10241026
safe = ~pos.pieces(Them);
@@ -1028,29 +1030,29 @@ namespace {
10281030
#ifdef CRAZYHOUSE
10291031
h = pos.is_house() && pos.count_in_hand<ROOK>(Them) ? ~pos.pieces() : 0;
10301032
#endif
1031-
if (b1 & safe)
1033+
if (b1 & ((attackedBy[Them][ROOK] & safe) | (h & dropSafe)))
10321034
kingDanger += RookSafeCheck;
10331035
else
1034-
unsafeChecks |= b1;
1036+
unsafeChecks |= b1 & (attackedBy[Them][ROOK] | h);
10351037

10361038
// Enemy bishops checks
10371039
#ifdef CRAZYHOUSE
10381040
h = pos.is_house() && pos.count_in_hand<BISHOP>(Them) ? ~pos.pieces() : 0;
10391041
#endif
1040-
if (b2 & safe)
1042+
if (b2 & ((attackedBy[Them][BISHOP] & safe) | (h & dropSafe)))
10411043
kingDanger += BishopSafeCheck;
10421044
else
1043-
unsafeChecks |= b2;
1045+
unsafeChecks |= b2 & (attackedBy[Them][BISHOP] | h);
10441046

10451047
// Enemy knights checks
1048+
b = pos.attacks_from<KNIGHT>(ksq);
10461049
#ifdef CRAZYHOUSE
10471050
h = pos.is_house() && pos.count_in_hand<KNIGHT>(Them) ? ~pos.pieces() : 0;
10481051
#endif
1049-
b = pos.attacks_from<KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
1050-
if (b & safe)
1052+
if (b & ((attackedBy[Them][KNIGHT] & safe) | (h & dropSafe)))
10511053
kingDanger += KnightSafeCheck;
10521054
else
1053-
unsafeChecks |= b;
1055+
unsafeChecks |= b & (attackedBy[Them][KNIGHT] | h);
10541056

10551057
// Unsafe or occupied checking squares will also be considered, as long as
10561058
// the square is not defended by our pawns or occupied by a blocked pawn.

0 commit comments

Comments
 (0)