feat: value network trained on Lc0 data
The static evaluation behind the quiescence search is now a (768 -> 128)x2 -> 1 SCReLU network instead of the hand-written evaluation. It was trained with bullet on linrock's Lc0-derived test80 2024-02 binpack, 40 superbatches (10 min on an RTX 3070), final loss 0.0220. The quiescence search itself is unchanged. The network is embedded with incbin (EVALFILE, default networks/rigby-value-v1.bin). Q is tanh(cp / 800), the same scale the network was trained on (sigmoid(cp / 400) = expected score). Checked: bullet's float evaluation of fixed positions (trainer --check) and the engine's quantised inference (evalfens) agree within 6 cp; an integer re-implementation in Python matches the engine exactly. Perft passes, bench is deterministic. Bench: 545914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
530c4d67ed
commit
30b0c36cd5
14 files changed
+700
-68
No files matched your search
+20
@@ -1,6 +1,7 @@
|
||||
#include "uci.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
@@ -229,6 +230,25 @@ void uci_loop() {
|
||||
} else if (cmd == "eval") {
|
||||
send("static " + std::to_string(eval::static_eval(e.pos)) + " cp, qsearch " +
|
||||
std::to_string(eval::quiescence(e.pos, -30000, 30000, 0)) + " cp (side to move)");
|
||||
} else if (cmd == "evalfens") {
|
||||
// Same positions as the trainer's --check, to compare inference
|
||||
static constexpr const char* FENS[] = {
|
||||
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1",
|
||||
"rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR b KQkq - 0 1",
|
||||
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq - 0 1",
|
||||
"r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R b KQkq - 0 1",
|
||||
"6k1/5pp1/1p2p2p/1Pq1Pn2/2P2P2/6P1/4Q1BP/6K1 w - - 1 30",
|
||||
"8/8/3k4/2p1p3/2P1P3/3K4/8/8 w - - 0 1",
|
||||
"4k3/8/8/8/8/8/8/R3K3 w - - 0 1",
|
||||
"4k3/8/8/8/8/8/8/R3K3 b - - 0 1",
|
||||
};
|
||||
for (const char* fen : FENS) {
|
||||
Position pos;
|
||||
pos.set_fen(fen);
|
||||
char line[160];
|
||||
std::snprintf(line, sizeof(line), "%6d cp %s", eval::static_eval(pos), fen);
|
||||
send(line);
|
||||
}
|
||||
} else if (cmd == "perft") {
|
||||
int depth = 5;
|
||||
is >> depth;
|
||||
|
||||
Reference in new issue
Block a user