mirror of
https://github.com/sockspls/badfish
synced 2025-05-01 01:03:09 +00:00
Add an UCI level command "export_net".
This command writes the embedded net to the file `EvalFileDefaultName`. If there is no embedded net the command does nothing. fixes #3453 closes https://github.com/official-stockfish/Stockfish/pull/3454 No functional change
This commit is contained in:
parent
b1c8840f10
commit
ca250e969c
4 changed files with 23 additions and 6 deletions
16
README.md
16
README.md
|
@ -143,22 +143,26 @@ For users, the following UCI options, which can typically be set via a GUI, are
|
||||||
|
|
||||||
For developers the following non-standard commands might be of interest, mainly useful for debugging:
|
For developers the following non-standard commands might be of interest, mainly useful for debugging:
|
||||||
|
|
||||||
* #### compiler
|
|
||||||
Give information about the compiler and environment used for building a binary.
|
|
||||||
|
|
||||||
* #### flip
|
|
||||||
Flips the side to move.
|
|
||||||
|
|
||||||
* #### bench ttSize threads limit fenFile limitType evalType
|
* #### bench ttSize threads limit fenFile limitType evalType
|
||||||
Performs a standard benchmark using various options. The signature or standard node
|
Performs a standard benchmark using various options. The signature or standard node
|
||||||
count is obtained using all defaults. `bench` is currently `bench 16 1 13 default depth mixed`.
|
count is obtained using all defaults. `bench` is currently `bench 16 1 13 default depth mixed`.
|
||||||
|
|
||||||
|
* #### compiler
|
||||||
|
Give information about the compiler and environment used for building a binary.
|
||||||
|
|
||||||
* #### d
|
* #### d
|
||||||
Display the current position, with ascii art and fen.
|
Display the current position, with ascii art and fen.
|
||||||
|
|
||||||
* #### eval
|
* #### eval
|
||||||
Return the evaluation of the current position.
|
Return the evaluation of the current position.
|
||||||
|
|
||||||
|
* #### export_net
|
||||||
|
If the binary contains an embedded net, save it in a file (named according to the default value of EvalFile).
|
||||||
|
|
||||||
|
* #### flip
|
||||||
|
Flips the side to move.
|
||||||
|
|
||||||
|
|
||||||
## A note on classical evaluation versus NNUE evaluation
|
## A note on classical evaluation versus NNUE evaluation
|
||||||
|
|
||||||
Both approaches assign a value to a position that is used in alpha-beta (PVS) search
|
Both approaches assign a value to a position that is used in alpha-beta (PVS) search
|
||||||
|
|
|
@ -47,7 +47,9 @@
|
||||||
// Note that this does not work in Microsoft Visual Studio.
|
// Note that this does not work in Microsoft Visual Studio.
|
||||||
#if !defined(_MSC_VER) && !defined(NNUE_EMBEDDING_OFF)
|
#if !defined(_MSC_VER) && !defined(NNUE_EMBEDDING_OFF)
|
||||||
INCBIN(EmbeddedNNUE, EvalFileDefaultName);
|
INCBIN(EmbeddedNNUE, EvalFileDefaultName);
|
||||||
|
constexpr bool gHasEmbeddedNet = true;
|
||||||
#else
|
#else
|
||||||
|
constexpr bool gHasEmbeddedNet = false;
|
||||||
const unsigned char gEmbeddedNNUEData[1] = {0x0};
|
const unsigned char gEmbeddedNNUEData[1] = {0x0};
|
||||||
const unsigned char *const gEmbeddedNNUEEnd = &gEmbeddedNNUEData[1];
|
const unsigned char *const gEmbeddedNNUEEnd = &gEmbeddedNNUEData[1];
|
||||||
const unsigned int gEmbeddedNNUESize = 1;
|
const unsigned int gEmbeddedNNUESize = 1;
|
||||||
|
@ -114,6 +116,15 @@ namespace Eval {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NNUE::export_net() {
|
||||||
|
if constexpr (gHasEmbeddedNet) {
|
||||||
|
ofstream stream(EvalFileDefaultName, std::ios_base::binary);
|
||||||
|
stream.write(reinterpret_cast<const char*>(gEmbeddedNNUEData), gEmbeddedNNUESize);
|
||||||
|
} else {
|
||||||
|
sync_cout << "No embedded network file." << sync_endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// NNUE::verify() verifies that the last net used was loaded successfully
|
/// NNUE::verify() verifies that the last net used was loaded successfully
|
||||||
void NNUE::verify() {
|
void NNUE::verify() {
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace Eval {
|
||||||
Value evaluate(const Position& pos);
|
Value evaluate(const Position& pos);
|
||||||
bool load_eval(std::string name, std::istream& stream);
|
bool load_eval(std::string name, std::istream& stream);
|
||||||
void init();
|
void init();
|
||||||
|
void export_net();
|
||||||
void verify();
|
void verify();
|
||||||
|
|
||||||
} // namespace NNUE
|
} // namespace NNUE
|
||||||
|
|
|
@ -277,6 +277,7 @@ void UCI::loop(int argc, char* argv[]) {
|
||||||
else if (token == "d") sync_cout << pos << sync_endl;
|
else if (token == "d") sync_cout << pos << sync_endl;
|
||||||
else if (token == "eval") trace_eval(pos);
|
else if (token == "eval") trace_eval(pos);
|
||||||
else if (token == "compiler") sync_cout << compiler_info() << sync_endl;
|
else if (token == "compiler") sync_cout << compiler_info() << sync_endl;
|
||||||
|
else if (token == "export_net") Eval::NNUE::export_net();
|
||||||
else if (!token.empty() && token[0] != '#')
|
else if (!token.empty() && token[0] != '#')
|
||||||
sync_cout << "Unknown command: " << cmd << sync_endl;
|
sync_cout << "Unknown command: " << cmd << sync_endl;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue