Skip to content

Commit

Permalink
Bench: 20247146
Browse files Browse the repository at this point in the history
  • Loading branch information
TerjeKir committed Sep 25, 2023
1 parent 949d4e7 commit 0620ce1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/evaluate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/psqt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/tuner/tuner.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -178,6 +179,7 @@ static void InitBaseParams(TVector tparams) {
InitBaseSingle(PawnOpen);
InitBaseSingle(BishopPair);
InitBaseSingle(KingAtkPawn);
InitBaseSingle(KingNoAdv);
InitBaseSingle(OpenForward);
InitBaseSingle(SemiForward);
InitBaseSingle(NBBehindPawn);
Expand Down Expand Up @@ -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, "");
Expand Down Expand Up @@ -317,6 +320,7 @@ static void InitCoefficients(TCoeffs coeffs) {
InitCoeffSingle(PawnOpen);
InitCoeffSingle(BishopPair);
InitCoeffSingle(KingAtkPawn);
InitCoeffSingle(KingNoAdv);
InitCoeffSingle(OpenForward);
InitCoeffSingle(SemiForward);
InitCoeffSingle(NBBehindPawn);
Expand Down
3 changes: 2 additions & 1 deletion src/tuner/tuner.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 0620ce1

Please sign in to comment.