Skip to content

Commit 73e12e2

Browse files
committed
SPSA Tuning and Eval Normalization
Elo | 2.70 +- 2.65 (95%) SPRT | 10.0+0.10s Threads=1 Hash=8MB LLR | 2.90 (-2.25, 2.89) [0.00, 3.00] Games | N: 32054 W: 7938 L: 7689 D: 16427 Penta | [161, 3655, 8135, 3926, 150] Elo | 2.94 +- 2.95 (95%) SPRT | 60.0+0.60s Threads=1 Hash=64MB LLR | 2.92 (-2.25, 2.89) [0.00, 3.00] Games | N: 25508 W: 6229 L: 6013 D: 13266 Penta | [24, 2754, 6988, 2958, 30] BENCH : 3,271,193 Normalization using Vondele's scripts; From some SPSA tuning session games. Image: https://i.imgur.com/bnqbfMY.png
1 parent 0fdfb8c commit 73e12e2

File tree

4 files changed

+39
-28
lines changed

4 files changed

+39
-28
lines changed

src/search.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
#include "windows.h"
4747

4848
int LMRTable[64][64];
49-
int LateMovePruningCounts[2][9];
49+
int LateMovePruningCounts[2][11];
5050

5151
volatile int ABORT_SIGNAL; // Global ABORT flag for threads
5252
volatile int IS_PONDERING; // Global PONDER flag for threads
@@ -152,11 +152,11 @@ void initSearch() {
152152
// Init Late Move Reductions Table
153153
for (int depth = 1; depth < 64; depth++)
154154
for (int played = 1; played < 64; played++)
155-
LMRTable[depth][played] = 0.75 + log(depth) * log(played) / 2.25;
155+
LMRTable[depth][played] = 0.8180 + log(depth) * log(played) / 2.4760;
156156

157-
for (int depth = 1; depth < 9; depth++) {
158-
LateMovePruningCounts[0][depth] = 2.5 + 2 * depth * depth / 4.5;
159-
LateMovePruningCounts[1][depth] = 4.0 + 4 * depth * depth / 4.5;
157+
for (int depth = 1; depth <= 10; depth++) {
158+
LateMovePruningCounts[0][depth] = 2.1719 + 0.4048 * depth * depth;
159+
LateMovePruningCounts[1][depth] = 3.9498 + 0.7760 * depth * depth;
160160
}
161161
}
162162

@@ -515,7 +515,7 @@ int search(Thread *thread, PVariation *pv, int alpha, int beta, int depth, bool
515515
&& (!ttHit || !(ttBound & BOUND_UPPER) || ttValue >= beta)) {
516516

517517
// Dynamic R based on Depth, Eval, and Tactical state
518-
R = 4 + depth / 6 + MIN(3, (eval - beta) / 200) + (ns-1)->tactical;
518+
R = 4 + depth / 5 + MIN(3, (eval - beta) / 191) + (ns-1)->tactical;
519519

520520
apply(thread, board, NULL_MOVE);
521521
value = -search(thread, &lpv, -beta, -beta+1, depth-R, !cutnode);
@@ -698,7 +698,7 @@ int search(Thread *thread, PVariation *pv, int alpha, int beta, int depth, bool
698698
R -= ns->mp.stage < STAGE_QUIET;
699699

700700
// Adjust based on history scores
701-
R -= MAX(-2, MIN(2, hist / 5000));
701+
R -= MAX(-2, MIN(2, hist / 5770));
702702
}
703703

704704
// Step 18B (~3 elo). Noisy Late Move Reductions. The same as Step 18A, but
@@ -707,7 +707,7 @@ int search(Thread *thread, PVariation *pv, int alpha, int beta, int depth, bool
707707
else {
708708

709709
// Initialize R based on Capture History
710-
R = 2 - (hist / 5000);
710+
R = 2 - (hist / 5128);
711711

712712
// Reduce for moves that give check
713713
R -= !!board->kingAttackers;
@@ -1033,7 +1033,7 @@ int singularity(Thread *thread, uint16_t ttMove, int ttValue, int depth, int PvN
10331033
else applyLegal(thread, board, ttMove);
10341034

10351035
bool double_extend = !PvNode
1036-
&& value < rBeta - 15
1036+
&& value < rBeta - 16
10371037
&& (ns-1)->dextensions <= 6;
10381038

10391039
return double_extend ? 2 // Double extension in some non-pv nodes

src/search.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,43 +38,43 @@ int qsearch(Thread *thread, PVariation *pv, int alpha, int beta);
3838
int staticExchangeEvaluation(Board *board, uint16_t move, int threshold);
3939
int singularity(Thread *thread, uint16_t ttMove, int ttValue, int depth, int PvNode, int alpha, int beta, bool cutnode);
4040

41-
static const int WindowDepth = 5;
41+
static const int WindowDepth = 4;
4242
static const int WindowSize = 10;
4343
static const int WindowTimerMS = 2500;
4444

4545
static const int CurrmoveTimerMS = 2500;
4646

47-
static const int TTResearchMargin = 128;
47+
static const int TTResearchMargin = 137;
4848

4949
static const int BetaPruningDepth = 8;
50-
static const int BetaMargin = 75;
50+
static const int BetaMargin = 62;
5151

52-
static const int AlphaPruningDepth = 5;
53-
static const int AlphaMargin = 3000;
52+
static const int AlphaPruningDepth = 4;
53+
static const int AlphaMargin = 3328;
5454

5555
static const int NullMovePruningDepth = 2;
5656

5757
static const int ProbCutDepth = 5;
58-
static const int ProbCutMargin = 100;
58+
static const int ProbCutMargin = 98;
5959

6060
static const int FutilityPruningDepth = 8;
61-
static const int FutilityMarginBase = 92;
62-
static const int FutilityMarginPerDepth = 59;
63-
static const int FutilityMarginNoHistory = 158;
64-
static const int FutilityPruningHistoryLimit[] = { 12000, 6000 };
61+
static const int FutilityMarginBase = 76;
62+
static const int FutilityMarginPerDepth = 51;
63+
static const int FutilityMarginNoHistory = 162;
64+
static const int FutilityPruningHistoryLimit[] = { 13954, 5789 };
6565

6666
static const int ContinuationPruningDepth[] = { 3, 2 };
6767
static const int ContinuationPruningHistoryLimit[] = { -1000, -2500 };
6868

69-
static const int LateMovePruningDepth = 8;
69+
static const int LateMovePruningDepth = 7;
7070

7171
static const int SEEPruningDepth = 9;
7272
static const int SEEQuietMargin = -64;
7373
static const int SEENoisyMargin = -19;
7474
static const int SEEPieceValues[] = {
75-
100, 450, 450, 675,
76-
1300, 0, 0, 0,
75+
104, 419, 447, 693,
76+
1316, 0, 0, 0,
7777
};
7878

79-
static const int QSSeeMargin = 110;
80-
static const int QSDeltaMargin = 150;
79+
static const int QSSeeMargin = 116;
80+
static const int QSDeltaMargin = 149;

src/uci.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
#include "uci.h"
4343
#include "zobrist.h"
4444

45+
int NORMALIZE_EVAL = 1;
46+
4547
extern int MoveOverhead; // Defined by time.c
4648
extern unsigned TB_PROBE_DEPTH; // Defined by syzygy.c
4749
extern volatile int ABORT_SIGNAL; // Defined by search.c
@@ -104,7 +106,7 @@ int main(int argc, char **argv) {
104106
printf("option name SyzygyPath type string default <empty>\n");
105107
printf("option name SyzygyProbeDepth type spin default 0 min 0 max 127\n");
106108
printf("option name Ponder type check default false\n");
107-
printf("option name AnalysisMode type check default false\n");
109+
printf("option name Normalize type check default true\n");
108110
printf("option name UCI_Chess960 type check default false\n");
109111
printf("info string licensed to " LICENSE_OWNER "\n");
110112
printf("uciok\n"), fflush(stdout);
@@ -228,6 +230,7 @@ void uciSetOption(char *str, Thread **threads, int *multiPV, int *chess960) {
228230
// MoveOverhead : Overhead on time allocation to avoid time losses
229231
// SyzygyPath : Path to Syzygy Tablebases
230232
// SyzygyProbeDepth : Minimal Depth to probe the highest cardinality Tablebase
233+
// Normalize : Normalize UCI output to hope that +1.00 is 50% Won, 50% Drawn
231234
// UCI_Chess960 : Set when playing FRC, but not required in order to work
232235

233236
if (strStartsWith(str, "setoption name Hash value ")) {
@@ -268,6 +271,13 @@ void uciSetOption(char *str, Thread **threads, int *multiPV, int *chess960) {
268271
printf("info string set SyzygyProbeDepth to %u\n", TB_PROBE_DEPTH);
269272
}
270273

274+
if (strStartsWith(str, "setoption name Normalize value ")) {
275+
if (strStartsWith(str, "setoption name Normalize value true"))
276+
printf("info string set Normalize to true\n"), NORMALIZE_EVAL = 1;
277+
if (strStartsWith(str, "setoption name Normalize value false"))
278+
printf("info string set Normalize to false\n"), NORMALIZE_EVAL = 0;
279+
}
280+
271281
if (strStartsWith(str, "setoption name UCI_Chess960 value ")) {
272282
if (strStartsWith(str, "setoption name UCI_Chess960 value true"))
273283
printf("info string set UCI_Chess960 to true\n"), *chess960 = 1;
@@ -347,8 +357,9 @@ void uciReport(Thread *threads, PVariation *pv, int alpha, int beta) {
347357
int nps = (int)(1000 * (nodes / (1 + elapsed)));
348358

349359
// If the score is MATE or MATED in X, convert to X
350-
int score = bounded >= MATE_IN_MAX ? (MATE - bounded + 1) / 2
351-
: bounded <= -MATE_IN_MAX ? -(bounded + MATE) / 2 : bounded;
360+
int score = bounded >= MATE_IN_MAX ? (MATE - bounded + 1) / 2
361+
: bounded <= -MATE_IN_MAX ? -(bounded + MATE) / 2
362+
: NORMALIZE_EVAL ? 100 * bounded / 186 : bounded;
352363

353364
// Two possible score types, mate and cp = centipawns
354365
char *type = abs(bounded) >= MATE_IN_MAX ? "mate" : "cp";

src/uci.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "types.h"
2525

26-
#define VERSION_ID "14.24"
26+
#define VERSION_ID "14.25"
2727

2828
#ifndef LICENSE_OWNER
2929
#define LICENSE_OWNER "Unlicensed"

0 commit comments

Comments
 (0)