From 0620ce11a74ae000a5d24ca8dae31687fc0a7258 Mon Sep 17 00:00:00 2001 From: Terje Date: Mon, 25 Sep 2023 23:43:30 +0200 Subject: [PATCH] Bench: 20247146 --- src/evaluate.c | 12 ++++++++++++ src/psqt.c | 2 +- src/tuner/tuner.c | 4 ++++ src/tuner/tuner.h | 3 ++- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/evaluate.c b/src/evaluate.c index af1d34f4..797d092c 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -63,6 +63,7 @@ const int PushThreat = S( 25, 6); const int PawnOpen = S(-14,-19); const int BishopPair = S( 33,110); const int KingAtkPawn = S(-16, 45); +const int KingNoAdv = S( 3,-34); const int OpenForward = S( 28, 31); const int SemiForward = S( 17, 15); const int NBBehindPawn = S( 9, 32); @@ -316,6 +317,8 @@ INLINE int EvalPiece(const Position *pos, EvalInfo *ei, const Color color, const // Evaluates kings INLINE int EvalKings(const Position *pos, EvalInfo *ei, const Color color) { + const Direction up = color == WHITE ? NORTH : SOUTH; + int eval = 0; Square kingSq = kingSq(color); @@ -334,6 +337,15 @@ INLINE int EvalKings(const Position *pos, EvalInfo *ei, const Color color) { TraceIncr(KingAtkPawn); } + if (RelativeRank(color, RankOf(kingSq)) == RANK_1) { + Bitboard forward = AttackBB(KING, kingSq, 0) & RankBB[RankOf(kingSq + up)]; + + if (!(forward & ~(colorBB(color) | ei->attackedBy[!color][ALL]))) { + eval += KingNoAdv; + TraceIncr(KingNoAdv); + } + } + // King safety ei->attackPower[!color] += (count - 3) * 8; diff --git a/src/psqt.c b/src/psqt.c index 158093c7..02911911 100644 --- a/src/psqt.c +++ b/src/psqt.c @@ -81,7 +81,7 @@ const int PieceSqValue[6][64] = { S( 25, 31), S(114, 68), S(119,107), S( 36,146), S( 79,134), S(114,108), S(111, 74), S(-41, 68), S( 32, 25), S(117, 55), S( 86, 83), S( 63,103), S( 81, 99), S( 69, 90), S( 86, 67), S( -3, 52), S( 85, 25), S( 84, 50), S( 72, 66), S( 19, 86), S( 31, 86), S( 47, 75), S( 84, 50), S( 60, 25), - S( 37,-41), S( 89, -1), S( 64, 30), S(-39, 43), S( 33, 17), S(-18, 50), S( 66, 3), S( 36,-41) }, + S( 37,-40), S( 97, -8), S( 71, 25), S(-40, 45), S( 38, 16), S( -8, 46), S( 72, -1), S( 34,-35) }, }; // Initialize the piece square tables with piece values included diff --git a/src/tuner/tuner.c b/src/tuner/tuner.c index dd974906..a320df6b 100644 --- a/src/tuner/tuner.c +++ b/src/tuner/tuner.c @@ -51,6 +51,7 @@ extern const int PushThreat; extern const int PawnOpen; extern const int BishopPair; extern const int KingAtkPawn; +extern const int KingNoAdv; extern const int OpenForward; extern const int SemiForward; extern const int NBBehindPawn; @@ -178,6 +179,7 @@ static void InitBaseParams(TVector tparams) { InitBaseSingle(PawnOpen); InitBaseSingle(BishopPair); InitBaseSingle(KingAtkPawn); + InitBaseSingle(KingNoAdv); InitBaseSingle(OpenForward); InitBaseSingle(SemiForward); InitBaseSingle(NBBehindPawn); @@ -250,6 +252,7 @@ static void PrintParameters(TVector updates, TVector base) { PrintSingle(PawnOpen, " "); PrintSingle(BishopPair, " "); PrintSingle(KingAtkPawn, " "); + PrintSingle(KingNoAdv, " "); PrintSingle(OpenForward, " "); PrintSingle(SemiForward, " "); PrintSingle(NBBehindPawn, ""); @@ -317,6 +320,7 @@ static void InitCoefficients(TCoeffs coeffs) { InitCoeffSingle(PawnOpen); InitCoeffSingle(BishopPair); InitCoeffSingle(KingAtkPawn); + InitCoeffSingle(KingNoAdv); InitCoeffSingle(OpenForward); InitCoeffSingle(SemiForward); InitCoeffSingle(NBBehindPawn); diff --git a/src/tuner/tuner.h b/src/tuner/tuner.h index ba1e34ae..b70f417c 100644 --- a/src/tuner/tuner.h +++ b/src/tuner/tuner.h @@ -49,7 +49,7 @@ // #define NPOSITIONS (14669229) // Total FENS in the book -#define NTERMS ( 552) // Number of terms being tuned +#define NTERMS ( 553) // Number of terms being tuned #define MAXEPOCHS ( 10000) // Max number of epochs allowed #define REPORTING ( 50) // How often to print the new parameters #define NPARTITIONS ( 64) // Total thread partitions @@ -80,6 +80,7 @@ typedef struct EvalTrace { int PawnOpen[COLOR_NB]; int BishopPair[COLOR_NB]; int KingAtkPawn[COLOR_NB]; + int KingNoAdv[COLOR_NB]; int OpenForward[COLOR_NB]; int SemiForward[COLOR_NB]; int NBBehindPawn[COLOR_NB];