mirror of
https://github.com/sockspls/badfish
synced 2025-04-29 16:23:09 +00:00
More precise checks evaluation in king danger
Remove overlapping safe checks from kingdanger: - rook and queen checks from the same square: rook check is preferred - bishop and queen checks form the same square: queen check is preferred Increase bishop and rook check values as a compensation. STC LLR: 2.95 (-2.94,2.94) [0.50,4.50] Total: 27480 W: 6111 L: 5813 D: 15556 http://tests.stockfishchess.org/tests/view/5c521d050ebc593af5d4e66a LTC LLR: 2.95 (-2.94,2.94) [0.00,3.50] Total: 78500 W: 13145 L: 12752 D: 52603 http://tests.stockfishchess.org/tests/view/5c52b9460ebc592fc7baecc5 Closes https://github.com/official-stockfish/Stockfish/pull/1983 ------------------------------------------ I have quite a few ideas of how to improve this patch. - actually rethinking it now it will maybe be useful to discount queen/bishop checks if there is only one square that they can give check from and it's "occupied" by more valuable check. Right now count of this squares does not really matter. - maybe some small extra bonus can be given for overlapping checks. - some ideas about using popcount() on safechecks can be retried. - tune this safecheck values since they were more or less randomly handcrafted in this patch. Bench: 3216489
This commit is contained in:
parent
d1fd1a96bc
commit
3f7ec977cd
1 changed files with 29 additions and 14 deletions
|
@ -93,8 +93,8 @@ namespace {
|
|||
|
||||
// Penalties for enemy's safe checks
|
||||
constexpr int QueenSafeCheck = 780;
|
||||
constexpr int RookSafeCheck = 880;
|
||||
constexpr int BishopSafeCheck = 435;
|
||||
constexpr int RookSafeCheck = 1080;
|
||||
constexpr int BishopSafeCheck = 635;
|
||||
constexpr int KnightSafeCheck = 790;
|
||||
|
||||
#define S(mg, eg) make_score(mg, eg)
|
||||
|
@ -434,27 +434,42 @@ namespace {
|
|||
b1 = attacks_bb<ROOK >(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN));
|
||||
b2 = attacks_bb<BISHOP>(ksq, pos.pieces() ^ pos.pieces(Us, QUEEN));
|
||||
|
||||
// Enemy queen safe checks
|
||||
if ((b1 | b2) & attackedBy[Them][QUEEN] & safe & ~attackedBy[Us][QUEEN])
|
||||
kingDanger += QueenSafeCheck;
|
||||
|
||||
b1 &= attackedBy[Them][ROOK];
|
||||
b2 &= attackedBy[Them][BISHOP];
|
||||
|
||||
// Enemy rooks checks
|
||||
if (b1 & safe)
|
||||
Bitboard RookCheck = b1
|
||||
& safe
|
||||
& attackedBy[Them][ROOK];
|
||||
|
||||
if (RookCheck)
|
||||
kingDanger += RookSafeCheck;
|
||||
else
|
||||
unsafeChecks |= b1;
|
||||
unsafeChecks |= b1 & attackedBy[Them][ROOK];
|
||||
|
||||
// Enemy bishops checks
|
||||
if (b2 & safe)
|
||||
// Enemy queen safe checks: we count them only if they are from squares from
|
||||
// which we can't give a rook check, because rook checks are more valuable.
|
||||
Bitboard QueenCheck = (b1 | b2)
|
||||
& attackedBy[Them][QUEEN]
|
||||
& safe
|
||||
& ~attackedBy[Us][QUEEN]
|
||||
& ~RookCheck;
|
||||
|
||||
if (QueenCheck)
|
||||
kingDanger += QueenSafeCheck;
|
||||
|
||||
// Enemy bishops checks: we count them only if they are from squares from
|
||||
// which we can't give a queen check, because queen checks are more valuable.
|
||||
Bitboard BishopCheck = b2
|
||||
& attackedBy[Them][BISHOP]
|
||||
& safe
|
||||
& ~QueenCheck;
|
||||
|
||||
if (BishopCheck)
|
||||
kingDanger += BishopSafeCheck;
|
||||
else
|
||||
unsafeChecks |= b2;
|
||||
unsafeChecks |= b2 & attackedBy[Them][BISHOP];
|
||||
|
||||
// Enemy knights checks
|
||||
b = pos.attacks_from<KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
|
||||
|
||||
if (b & safe)
|
||||
kingDanger += KnightSafeCheck;
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue