From a87a1005ad63c8076a79ea3b2648f87fea49cfc5 Mon Sep 17 00:00:00 2001 From: Stefan Geschwentner Date: Sun, 3 Dec 2017 10:41:48 +0100 Subject: [PATCH] Attack threats Give bonus for safe attack threats from bishops and rooks on opponent queen STC: LLR: 2.97 (-2.94,2.94) [0.00,5.00] Total: 8629 W: 1599 L: 1438 D: 5592 http://tests.stockfishchess.org/tests/view/5a1ad4490ebc590ccbb8b30d LTC: LLR: 2.96 (-2.94,2.94) [0.00,5.00] Total: 7093 W: 987 L: 846 D: 5260 http://tests.stockfishchess.org/tests/view/5a1aec5d0ebc590ccbb8b317 Bench: 5051254 --- src/evaluate.cpp | 48 +++++++++++++++++++++++++++++++----------------- src/types.h | 1 + 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/evaluate.cpp b/src/evaluate.cpp index 39dac6d1..e1061849 100644 --- a/src/evaluate.cpp +++ b/src/evaluate.cpp @@ -211,23 +211,24 @@ namespace { const Score KingProtector[] = { S(-3, -5), S(-4, -3), S(-3, 0), S(-1, 1) }; // Assorted bonuses and penalties used by evaluation - const Score MinorBehindPawn = S( 16, 0); - const Score BishopPawns = S( 8, 12); - const Score LongRangedBishop = S( 22, 0); - const Score RookOnPawn = S( 8, 24); - const Score TrappedRook = S( 92, 0); - const Score WeakQueen = S( 50, 10); - const Score OtherCheck = S( 10, 10); - const Score CloseEnemies = S( 7, 0); - const Score PawnlessFlank = S( 20, 80); - const Score ThreatByHangingPawn = S( 71, 61); - const Score ThreatBySafePawn = S(192,175); - const Score ThreatByRank = S( 16, 3); - const Score Hanging = S( 48, 27); - const Score WeakUnopposedPawn = S( 5, 25); - const Score ThreatByPawnPush = S( 38, 22); - const Score HinderPassedPawn = S( 7, 0); - const Score TrappedBishopA1H1 = S( 50, 50); + const Score MinorBehindPawn = S( 16, 0); + const Score BishopPawns = S( 8, 12); + const Score LongRangedBishop = S( 22, 0); + const Score RookOnPawn = S( 8, 24); + const Score TrappedRook = S( 92, 0); + const Score WeakQueen = S( 50, 10); + const Score OtherCheck = S( 10, 10); + const Score CloseEnemies = S( 7, 0); + const Score PawnlessFlank = S( 20, 80); + const Score ThreatByHangingPawn = S( 71, 61); + const Score ThreatBySafePawn = S(192,175); + const Score ThreatByRank = S( 16, 3); + const Score Hanging = S( 48, 27); + const Score WeakUnopposedPawn = S( 5, 25); + const Score ThreatByPawnPush = S( 38, 22); + const Score ThreatByAttackOnQueen = S( 38, 22); + const Score HinderPassedPawn = S( 7, 0); + const Score TrappedBishopA1H1 = S( 50, 50); #undef S #undef V @@ -303,6 +304,9 @@ namespace { attackedBy[Us][Pt] = 0; + if (Pt == QUEEN) + attackedBy[Us][QUEEN_DIAGONAL] = 0; + while ((s = *pl++) != SQ_NONE) { // Find attacked squares, including x-ray attacks for bishops and rooks @@ -316,6 +320,9 @@ namespace { attackedBy2[Us] |= attackedBy[Us][ALL_PIECES] & b; attackedBy[Us][ALL_PIECES] |= attackedBy[Us][Pt] |= b; + if (Pt == QUEEN) + attackedBy[Us][QUEEN_DIAGONAL] |= b & PseudoAttacks[BISHOP][s]; + if (b & kingRing[Them]) { kingAttackersCount[Us]++; @@ -609,6 +616,13 @@ namespace { score += ThreatByPawnPush * popcount(b); + // Add a bonus for safe slider attack threats on opponent queen + safeThreats = ~pos.pieces(Us) & ~attackedBy2[Them] & attackedBy2[Us]; + b = (attackedBy[Us][BISHOP] & attackedBy[Them][QUEEN_DIAGONAL]) + | (attackedBy[Us][ROOK ] & attackedBy[Them][QUEEN] & ~attackedBy[Them][QUEEN_DIAGONAL]); + + score += ThreatByAttackOnQueen * popcount(b & safeThreats); + if (T) Trace::add(THREAT, Us, score); diff --git a/src/types.h b/src/types.h index acca8743..a3004282 100644 --- a/src/types.h +++ b/src/types.h @@ -195,6 +195,7 @@ enum Value : int { enum PieceType { NO_PIECE_TYPE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, ALL_PIECES = 0, + QUEEN_DIAGONAL = 7, PIECE_TYPE_NB = 8 }; -- 2.39.2