Skip to content

Commit

Permalink
Fairy-Stockfish Xiangqi/Janggi NNUE
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfab committed Nov 19, 2021
1 parent b3a6aa1 commit 433d411
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/evaluate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,16 @@
// Note that this does not work in Microsoft Visual Studio.
#if !defined(_MSC_VER) && !defined(NNUE_EMBEDDING_OFF)
INCBIN(EmbeddedNNUE, EvalFileDefaultName);
INCBIN(EmbeddedNNUE2, EvalFile2DefaultName);
#else
const unsigned char gEmbeddedNNUEData[1] = {0x0};
[[maybe_unused]]
const unsigned char *const gEmbeddedNNUEEnd = &gEmbeddedNNUEData[1];
const unsigned int gEmbeddedNNUESize = 1;
const unsigned char gEmbeddedNNUE2Data[1] = {0x0};
[[maybe_unused]]
const unsigned char *const gEmbeddedNNUE2End = &gEmbeddedNNUE2Data[1];
const unsigned int gEmbeddedNNUE2Size = 1;
#endif


Expand Down Expand Up @@ -120,15 +125,16 @@ namespace Eval {
eval_file_loaded = eval_file;
}

if (directory == "<internal>" && eval_file == EvalFileDefaultName)
if (directory == "<internal>" && (eval_file == EvalFileDefaultName || eval_file == EvalFile2DefaultName))
{
// C++ way to prepare a buffer for a memory stream
class MemoryBuffer : public basic_streambuf<char> {
public: MemoryBuffer(char* p, size_t n) { setg(p, p, p + n); setp(p, p + n); }
};

MemoryBuffer buffer(const_cast<char*>(reinterpret_cast<const char*>(gEmbeddedNNUEData)),
size_t(gEmbeddedNNUESize));
bool first = eval_file == EvalFileDefaultName;
MemoryBuffer buffer(const_cast<char*>(reinterpret_cast<const char*>(first ? gEmbeddedNNUEData : gEmbeddedNNUE2Data)),
size_t(first ? gEmbeddedNNUESize : gEmbeddedNNUE2Size));

istream stream(&buffer);
if (load_eval(eval_file, stream))
Expand Down
3 changes: 2 additions & 1 deletion src/evaluate.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace Eval {
// The default net name MUST follow the format nn-[SHA256 first 12 digits].nnue
// for the build process (profile-build and fishtest) to work. Do not change the
// name of the macro, as it is used in the Makefile.
#define EvalFileDefaultName "nn-3475407dc199.nnue"
#define EvalFileDefaultName "xiangqi-83f16c17fe26.nnue"
#define EvalFile2DefaultName "janggi-85de3dae670a.nnue"

namespace NNUE {

Expand Down
4 changes: 2 additions & 2 deletions src/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace {

/// Version number. If Version is left empty, then compile date in the format
/// DD-MM-YY and show in engine_info.
const string Version = "";
const string Version = "14.0.1";

/// Our fancy logging facility. The trick here is to replace cin.rdbuf() and
/// cout.rdbuf() with two Tie objects that tie cin and cout to a file stream. We
Expand Down Expand Up @@ -155,7 +155,7 @@ string engine_info(bool to_uci, bool to_xboard) {
}

#ifdef LARGEBOARDS
ss << " LB";
ss << " XQ";
#endif

if (!to_xboard)
Expand Down
2 changes: 1 addition & 1 deletion src/ucioption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void init(OptionsMap& o) {
o["SyzygyProbeLimit"] << Option(7, 0, 7);
o["Use NNUE"] << Option(true, on_use_NNUE);
#ifndef NNUE_EMBEDDING_OFF
o["EvalFile"] << Option(EvalFileDefaultName, on_eval_file);
o["EvalFile"] << Option((std::string(EvalFileDefaultName) + UCI::SepChar + EvalFile2DefaultName).c_str(), on_eval_file);
#else
o["EvalFile"] << Option("<empty>", on_eval_file);
#endif
Expand Down

0 comments on commit 433d411

Please sign in to comment.