1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

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 https://github.com/official-stockfish/Stockfish/pull/2649

Bench 4800754
This commit is contained in:
Linmiao Xu 2020-04-25 15:55:35 -04:00 committed by Joost VandeVondele
parent 353e20674b
commit 7f8166db89
2 changed files with 17 additions and 13 deletions

View file

@ -42,6 +42,7 @@ Eelco de Groot (KingDefender)
Elvin Liu (solarlight2) Elvin Liu (solarlight2)
erbsenzaehler erbsenzaehler
Ernesto Gatti Ernesto Gatti
Linmiao Xu (linrock)
Fabian Beuke (madnight) Fabian Beuke (madnight)
Fabian Fichter (ianfab) Fabian Fichter (ianfab)
fanon fanon

View file

@ -81,10 +81,10 @@ namespace {
constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 }; constexpr int KingAttackWeights[PIECE_TYPE_NB] = { 0, 0, 81, 52, 44, 10 };
// Penalties for enemy's safe checks // Penalties for enemy's safe checks
constexpr int QueenSafeCheck = 780; constexpr int QueenSafeCheck = 772;
constexpr int RookSafeCheck = 1078; constexpr int RookSafeCheck = 1084;
constexpr int BishopSafeCheck = 635; constexpr int BishopSafeCheck = 645;
constexpr int KnightSafeCheck = 790; constexpr int KnightSafeCheck = 792;
#define S(mg, eg) make_score(mg, eg) #define S(mg, eg) make_score(mg, eg)
@ -131,11 +131,14 @@ namespace {
constexpr Score CorneredBishop = S( 50, 50); constexpr Score CorneredBishop = S( 50, 50);
constexpr Score FlankAttacks = S( 8, 0); constexpr Score FlankAttacks = S( 8, 0);
constexpr Score Hanging = S( 69, 36); constexpr Score Hanging = S( 69, 36);
constexpr Score KingProtector = S( 7, 8); constexpr Score BishopKingProtector = S( 6, 9);
constexpr Score KnightKingProtector = S( 8, 9);
constexpr Score KnightOnQueen = S( 16, 11); constexpr Score KnightOnQueen = S( 16, 11);
constexpr Score LongDiagonalBishop = S( 45, 0); constexpr Score LongDiagonalBishop = S( 45, 0);
constexpr Score MinorBehindPawn = S( 18, 3); constexpr Score MinorBehindPawn = S( 18, 3);
constexpr Score Outpost = S( 30, 21); constexpr Score KnightOutpost = S( 56, 36);
constexpr Score BishopOutpost = S( 30, 23);
constexpr Score ReachableOutpost = S( 31, 22);
constexpr Score PassedFile = S( 11, 8); constexpr Score PassedFile = S( 11, 8);
constexpr Score PawnlessFlank = S( 17, 95); constexpr Score PawnlessFlank = S( 17, 95);
constexpr Score RestrictedPiece = S( 7, 7); constexpr Score RestrictedPiece = S( 7, 7);
@ -293,17 +296,17 @@ namespace {
// Bonus if piece is on an outpost square or can reach one // Bonus if piece is on an outpost square or can reach one
bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them); bb = OutpostRanks & attackedBy[Us][PAWN] & ~pe->pawn_attacks_span(Them);
if (bb & s) if (bb & s)
score += Outpost * (Pt == KNIGHT ? 2 : 1); score += (Pt == KNIGHT) ? KnightOutpost : BishopOutpost;
else if (Pt == KNIGHT && bb & b & ~pos.pieces(Us)) else if (Pt == KNIGHT && bb & b & ~pos.pieces(Us))
score += Outpost; score += ReachableOutpost;
// Bonus for a knight or bishop shielded by pawn // Bonus for a knight or bishop shielded by pawn
if (shift<Down>(pos.pieces(PAWN)) & s) if (shift<Down>(pos.pieces(PAWN)) & s)
score += MinorBehindPawn; score += MinorBehindPawn;
// Penalty if the piece is far from the king // Penalty if the piece is far from the king
score -= KingProtector * distance(pos.square<KING>(Us), s); score -= (Pt == KNIGHT ? KnightKingProtector
: BishopKingProtector) * distance(pos.square<KING>(Us), s);
if (Pt == BISHOP) if (Pt == BISHOP)
{ {
@ -399,7 +402,7 @@ namespace {
// Enemy rooks checks // Enemy rooks checks
rookChecks = b1 & safe & attackedBy[Them][ROOK]; rookChecks = b1 & safe & attackedBy[Them][ROOK];
if (rookChecks) if (rookChecks)
kingDanger += more_than_one(rookChecks) ? RookSafeCheck * 3/2 kingDanger += more_than_one(rookChecks) ? RookSafeCheck * 175/100
: RookSafeCheck; : RookSafeCheck;
else else
unsafeChecks |= b1 & attackedBy[Them][ROOK]; unsafeChecks |= b1 & attackedBy[Them][ROOK];
@ -412,7 +415,7 @@ namespace {
& ~attackedBy[Us][QUEEN] & ~attackedBy[Us][QUEEN]
& ~rookChecks; & ~rookChecks;
if (queenChecks) if (queenChecks)
kingDanger += more_than_one(queenChecks) ? QueenSafeCheck * 3/2 kingDanger += more_than_one(queenChecks) ? QueenSafeCheck * 145/100
: QueenSafeCheck; : QueenSafeCheck;
// Enemy bishops checks: we count them only if they are from squares from // Enemy bishops checks: we count them only if they are from squares from
@ -430,7 +433,7 @@ namespace {
// Enemy knights checks // Enemy knights checks
knightChecks = pos.attacks_from<KNIGHT>(ksq) & attackedBy[Them][KNIGHT]; knightChecks = pos.attacks_from<KNIGHT>(ksq) & attackedBy[Them][KNIGHT];
if (knightChecks & safe) if (knightChecks & safe)
kingDanger += more_than_one(knightChecks & safe) ? KnightSafeCheck * 3/2 kingDanger += more_than_one(knightChecks & safe) ? KnightSafeCheck * 162/100
: KnightSafeCheck; : KnightSafeCheck;
else else
unsafeChecks |= knightChecks; unsafeChecks |= knightChecks;