1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 17:19:36 +00:00

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
This commit is contained in:
Stefan Geschwentner 2017-12-03 10:41:48 +01:00 committed by Marco Costalba
parent 7dd1f4a7c0
commit a87a1005ad
2 changed files with 32 additions and 17 deletions

View file

@ -226,6 +226,7 @@ namespace {
const Score Hanging = S( 48, 27); const Score Hanging = S( 48, 27);
const Score WeakUnopposedPawn = S( 5, 25); const Score WeakUnopposedPawn = S( 5, 25);
const Score ThreatByPawnPush = S( 38, 22); const Score ThreatByPawnPush = S( 38, 22);
const Score ThreatByAttackOnQueen = S( 38, 22);
const Score HinderPassedPawn = S( 7, 0); const Score HinderPassedPawn = S( 7, 0);
const Score TrappedBishopA1H1 = S( 50, 50); const Score TrappedBishopA1H1 = S( 50, 50);
@ -303,6 +304,9 @@ namespace {
attackedBy[Us][Pt] = 0; attackedBy[Us][Pt] = 0;
if (Pt == QUEEN)
attackedBy[Us][QUEEN_DIAGONAL] = 0;
while ((s = *pl++) != SQ_NONE) while ((s = *pl++) != SQ_NONE)
{ {
// Find attacked squares, including x-ray attacks for bishops and rooks // Find attacked squares, including x-ray attacks for bishops and rooks
@ -316,6 +320,9 @@ namespace {
attackedBy2[Us] |= attackedBy[Us][ALL_PIECES] & b; attackedBy2[Us] |= attackedBy[Us][ALL_PIECES] & b;
attackedBy[Us][ALL_PIECES] |= attackedBy[Us][Pt] |= b; attackedBy[Us][ALL_PIECES] |= attackedBy[Us][Pt] |= b;
if (Pt == QUEEN)
attackedBy[Us][QUEEN_DIAGONAL] |= b & PseudoAttacks[BISHOP][s];
if (b & kingRing[Them]) if (b & kingRing[Them])
{ {
kingAttackersCount[Us]++; kingAttackersCount[Us]++;
@ -609,6 +616,13 @@ namespace {
score += ThreatByPawnPush * popcount(b); 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) if (T)
Trace::add(THREAT, Us, score); Trace::add(THREAT, Us, score);

View file

@ -195,6 +195,7 @@ enum Value : int {
enum PieceType { enum PieceType {
NO_PIECE_TYPE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING, NO_PIECE_TYPE, PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING,
ALL_PIECES = 0, ALL_PIECES = 0,
QUEEN_DIAGONAL = 7,
PIECE_TYPE_NB = 8 PIECE_TYPE_NB = 8
}; };