Skip to content

Commit 7f8166d

Browse files
linrockvondele
authored andcommitted
Tuned safe checks and minor piece king protectors
A combination of terms related to king safety one tuned safe check weights, the other tuned knight and bishop king protector weights separately with some compensation in the high outpost bonuses given to the minor pieces. passed STC LLR: 2.95 (-2.94,2.94) {-0.50,1.50} Total: 39892 W: 7594 L: 7350 D: 24948 Ptnml(0-2): 643, 4559, 9314, 4771, 659 https://tests.stockfishchess.org/tests/view/5ea49635b908f6dd28f34b82 passed LTC LLR: 2.94 (-2.94,2.94) {0.25,1.75} Total: 104934 W: 13300 L: 12834 D: 78800 Ptnml(0-2): 697, 9571, 31514, 9939, 746 https://tests.stockfishchess.org/tests/view/5ea4abf6b908f6dd28f34bcb closes #2649 Bench 4800754
1 parent 353e206 commit 7f8166d

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ Eelco de Groot (KingDefender)
4242
Elvin Liu (solarlight2)
4343
erbsenzaehler
4444
Ernesto Gatti
45+
Linmiao Xu (linrock)
4546
Fabian Beuke (madnight)
4647
Fabian Fichter (ianfab)
4748
fanon

src/evaluate.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ namespace {
8181
constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 };
8282

8383
// Penalties for enemy's safe checks
84-
constexpr int QueenSafeCheck = 780;
85-
constexpr int RookSafeCheck = 1078;
86-
constexpr int BishopSafeCheck = 635;
87-
constexpr int KnightSafeCheck = 790;
84+
constexpr int QueenSafeCheck = 772;
85+
constexpr int RookSafeCheck = 1084;
86+
constexpr int BishopSafeCheck = 645;
87+
constexpr int KnightSafeCheck = 792;
8888

8989
#define S(mg, eg) make_score(mg, eg)
9090

@@ -131,11 +131,14 @@ namespace {
131131
constexpr Score CorneredBishop = S( 50, 50);
132132
constexpr Score FlankAttacks = S( 8, 0);
133133
constexpr Score Hanging = S( 69, 36);
134-
constexpr Score KingProtector = S( 7, 8);
134+
constexpr Score BishopKingProtector = S( 6, 9);
135+
constexpr Score KnightKingProtector = S( 8, 9);
135136
constexpr Score KnightOnQueen = S( 16, 11);
136137
constexpr Score LongDiagonalBishop = S( 45, 0);
137138
constexpr Score MinorBehindPawn = S( 18, 3);
138-
constexpr Score Outpost = S( 30, 21);
139+
constexpr Score KnightOutpost = S( 56, 36);
140+
constexpr Score BishopOutpost = S( 30, 23);
141+
constexpr Score ReachableOutpost = S( 31, 22);
139142
constexpr Score PassedFile = S( 11, 8);
140143
constexpr Score PawnlessFlank = S( 17, 95);
141144
constexpr Score RestrictedPiece = S( 7, 7);
@@ -293,17 +296,17 @@ namespace {
293296
// Bonus if piece is on an outpost square or can reach one
294297
bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them);
295298
if (bb & s)
296-
score += Outpost * (Pt == KNIGHT ? 2 : 1);
297-
299+
score += (Pt == KNIGHT) ? KnightOutpost : BishopOutpost;
298300
else if (Pt == KNIGHT && bb & b & ~pos.pieces(Us))
299-
score += Outpost;
301+
score += ReachableOutpost;
300302

301303
// Bonus for a knight or bishop shielded by pawn
302304
if (shift<Down>(pos.pieces(PAWN)) & s)
303305
score += MinorBehindPawn;
304306

305307
// Penalty if the piece is far from the king
306-
score -= KingProtector * distance(pos.square<KING>(Us), s);
308+
score -= (Pt == KNIGHT ? KnightKingProtector
309+
: BishopKingProtector) * distance(pos.square<KING>(Us), s);
307310

308311
if (Pt == BISHOP)
309312
{
@@ -399,7 +402,7 @@ namespace {
399402
// Enemy rooks checks
400403
rookChecks = b1 & safe & attackedBy[Them][ROOK];
401404
if (rookChecks)
402-
kingDanger += more_than_one(rookChecks) ? RookSafeCheck * 3/2
405+
kingDanger += more_than_one(rookChecks) ? RookSafeCheck * 175/100
403406
: RookSafeCheck;
404407
else
405408
unsafeChecks |= b1 & attackedBy[Them][ROOK];
@@ -412,7 +415,7 @@ namespace {
412415
& ~attackedBy[Us][QUEEN]
413416
& ~rookChecks;
414417
if (queenChecks)
415-
kingDanger += more_than_one(queenChecks) ? QueenSafeCheck * 3/2
418+
kingDanger += more_than_one(queenChecks) ? QueenSafeCheck * 145/100
416419
: QueenSafeCheck;
417420

418421
// Enemy bishops checks: we count them only if they are from squares from
@@ -430,7 +433,7 @@ namespace {
430433
// Enemy knights checks
431434
knightChecks = pos.attacks_from<KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
432435
if (knightChecks & safe)
433-
kingDanger += more_than_one(knightChecks & safe) ? KnightSafeCheck * 3/2
436+
kingDanger += more_than_one(knightChecks & safe) ? KnightSafeCheck * 162/100
434437
: KnightSafeCheck;
435438
else
436439
unsafeChecks |= knightChecks;

0 commit comments

Comments
 (0)