Nnue test #48

Merged
rektdie merged 14 commits from nnue_test into main 2025-04-09 03:23:41 +02:00
20 changed files with 10368 additions and 36 deletions

No files matched your search

+5 -6
View File
@@ -8,6 +8,8 @@ CXX ?= g++
# Set default executable name, but allow override from the command line
EXE ?= Eleanor
EVALFILE = ./nnue.bin
# Determine platform
ifeq ($(OS),Windows_NT)
EXE_EXT := .exe
@@ -26,12 +28,9 @@ MAKEFLAGS += -j
# List of source files
SRCS := $(wildcard $(SRC_DIR)/*.cpp)
# List of object files
OBJS := $(addprefix $(OBJ_DIR)/, $(notdir $(SRCS:.cpp=.o)))
# Target executable
$(EXE)$(EXE_EXT): $(OBJS)
$(CXX) -std=c++23 -o $@ $^ -O3 -lpthread -march=native -flto -ftree-vectorize
# Link the executable
$(EXE)$(EXE_EXT): $(SRCS)
$(CXX) $(CXXFLAGS) -DEVALFILE=\"$(EVALFILE)\" $(SRCS) ./external/fmt/format.cc -o $@ -O3 -lpthread -march=native -flto -ftree-vectorize
# Rule to compile source files to object files
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
+2985
View File
File diff suppressed because it is too large. Load diff
+1949
View File
File diff suppressed because it is too large. Load diff
+4244
View File
File diff suppressed because it is too large. Load diff
+46
View File
@@ -0,0 +1,46 @@
// Formatting library for C++
//
// Copyright (c) 2012 - 2016, Victor Zverovich
// All rights reserved.
//
// For the license information refer to format.h.
#include "fmt/format-inl.h"
FMT_BEGIN_NAMESPACE
namespace detail {
template FMT_API auto dragonbox::to_decimal(float x) noexcept
-> dragonbox::decimal_fp<float>;
template FMT_API auto dragonbox::to_decimal(double x) noexcept
-> dragonbox::decimal_fp<double>;
#if FMT_USE_LOCALE
// DEPRECATED! locale_ref in the detail namespace
template FMT_API locale_ref::locale_ref(const std::locale& loc);
template FMT_API auto locale_ref::get<std::locale>() const -> std::locale;
#endif
// Explicit instantiations for char.
template FMT_API auto thousands_sep_impl(locale_ref)
-> thousands_sep_result<char>;
template FMT_API auto decimal_point_impl(locale_ref) -> char;
// DEPRECATED!
template FMT_API void buffer<char>::append(const char*, const char*);
// DEPRECATED!
template FMT_API void vformat_to(buffer<char>&, string_view,
typename vformat_args<>::type, locale_ref);
// Explicit instantiations for wchar_t.
template FMT_API auto thousands_sep_impl(locale_ref)
-> thousands_sep_result<wchar_t>;
template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;
template FMT_API void buffer<wchar_t>::append(const wchar_t*, const wchar_t*);
} // namespace detail
FMT_END_NAMESPACE
+291
View File
@@ -0,0 +1,291 @@
#ifdef _MSC_VER
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <limits.h>
#ifndef PATH_MAX
# define PATH_MAX 260
#endif
#define SEARCH_PATHS_MAX 64
#define FILE_PATHS_MAX 1024
static int fline(char **line, size_t *n, FILE *fp) {
int chr;
char *pos;
if (!line || !n || !fp)
return -1;
if (!*line)
if (!(*line = (char *)malloc((*n=64))))
return -1;
chr = *n;
pos = *line;
for (;;) {
int c = fgetc(fp);
if (chr < 2) {
*n += (*n > 16) ? *n : 64;
chr = *n + *line - pos;
if (!(*line = (char *)realloc(*line,*n)))
return -1;
pos = *n - chr + *line;
}
if (ferror(fp))
return -1;
if (c == EOF) {
if (pos == *line)
return -1;
else
break;
}
*pos++ = c;
chr--;
if (c == '\n')
break;
}
*pos = '\0';
return pos - *line;
}
static FILE *open_file(const char *name, const char *mode, const char (*searches)[PATH_MAX], int count) {
int i;
for (i = 0; i < count; i++) {
char buffer[FILENAME_MAX + PATH_MAX];
FILE *fp;
#ifndef _MSC_VER
snprintf(buffer, sizeof(buffer), "%s/%s", searches[i], name);
#else
_snprintf(buffer, sizeof(buffer), "%s/%s", searches[i], name);
#endif
if ((fp = fopen(buffer, mode)))
return fp;
}
return !count ? fopen(name, mode) : NULL;
}
static int strcicmp(const char *s1, const char *s2) {
const unsigned char *us1 = (const unsigned char *)s1,
*us2 = (const unsigned char *)s2;
while (tolower(*us1) == tolower(*us2)) {
if (*us1++ == '\0')
return 0;
us2++;
}
return tolower(*us1) - tolower(*us2);
}
/* styles */
enum { kCamel, kSnake };
/* identifiers */
enum { kData, kEnd, kSize };
static const char *styled(int style, int ident) {
switch (style) {
case kCamel:
switch (ident) {
case kData: return "Data";
case kEnd: return "End";
case kSize: return "Size";
}
break;
case kSnake:
switch (ident) {
case kData: return "_data";
case kEnd: return "_end";
case kSize: return "_size";
}
break;
}
return "";
}
int main(int argc, char **argv) {
int ret = 0, i, paths, files = 0, style = kCamel;
char outfile[FILENAME_MAX] = "data.c";
char search_paths[SEARCH_PATHS_MAX][PATH_MAX];
char prefix[FILENAME_MAX] = "g";
char file_paths[FILE_PATHS_MAX][PATH_MAX];
FILE *out = NULL;
argc--;
argv++;
#define s(IDENT) styled(style, IDENT)
if (argc == 0) {
usage:
fprintf(stderr, "%s [-help] [-Ipath...] | <sourcefiles> | [-o output] | [-p prefix]\n", argv[-1]);
fprintf(stderr, " -o - output file [default is \"data.c\"]\n");
fprintf(stderr, " -p - specify a prefix for symbol names (default is \"g\")\n");
fprintf(stderr, " -S<style> - specify a style for symbol generation (default is \"camelcase\")\n");
fprintf(stderr, " -I<path> - specify an include path for the tool to use\n");
fprintf(stderr, " -help - this\n");
fprintf(stderr, "example:\n");
fprintf(stderr, " %s source.c other_source.cpp -o file.c\n", argv[-1]);
fprintf(stderr, "styles (for -S):\n");
fprintf(stderr, " camelcase\n");
fprintf(stderr, " snakecase\n");
return 1;
}
for (i = 0, paths = 0; i < argc; i++) {
if (!strcmp(argv[i], "-o")) {
if (i + 1 < argc) {
strcpy(outfile, argv[i + 1]);
memmove(argv+i+1, argv+i+2, (argc-i-2) * sizeof *argv);
argc--;
continue;
}
} else if (!strcmp(argv[i], "-p")) {
/* supports "-p" with no prefix as well as
* "-p -" which is another way of saying "no prefix"
* and "-p <prefix>" for an actual prefix.
*/
if (argv[i+1][0] == '-') {
prefix[0] = '\0';
/* is it just a -? */
if (i + 1 < argc && !strcmp(argv[i+1], "-")) {
memmove(argv+i+1, argv+i+2, (argc-i-2) * sizeof *argv);
argc--;
}
continue;
}
strcpy(prefix, argv[i + 1]);
memmove(argv+i+1, argv+i+2, (argc-i-2) * sizeof *argv);
argc--;
continue;
} else if (!strncmp(argv[i], "-I", 2)) {
char *name = argv[i] + 2; /* skip "-I"; */
if (paths >= SEARCH_PATHS_MAX) {
fprintf(stderr, "maximum search paths exceeded\n");
return 1;
}
strcpy(search_paths[paths++], name);
continue;
} else if (!strncmp(argv[i], "-S", 2)) {
char *name = argv[i] + 2; /* skip "-S"; */
if (!strcicmp(name, "camel") || !strcicmp(name, "camelcase"))
style = kCamel;
else if (!strcicmp(name, "snake") || !strcicmp(name, "snakecase"))
style = kSnake;
else
goto usage;
continue;
} else if (!strcmp(argv[i], "-help")) {
goto usage;
} else {
if (files >= sizeof file_paths / sizeof *file_paths) {
fprintf(stderr, "maximum file paths exceeded\n");
return 1;
}
strcpy(file_paths[files++], argv[i]);
}
}
if (!(out = fopen(outfile, "w"))) {
fprintf(stderr, "failed to open `%s' for output\n", outfile);
return 1;
}
fprintf(out, "/* File automatically generated by incbin */\n");
/* Be sure to define the prefix if we're not using the default */
if (strcmp(prefix, "g"))
fprintf(out, "#define INCBIN_PREFIX %s\n", prefix);
if (style != 0)
fprintf(out, "#define INCBIN_STYLE INCBIN_STYLE_SNAKE\n");
fprintf(out, "#include \"incbin.h\"\n\n");
fprintf(out, "#ifdef __cplusplus\n");
fprintf(out, "extern \"C\" {\n");
fprintf(out, "#endif\n\n");
for (i = 0; i < files; i++) {
FILE *fp = open_file(file_paths[i], "r", search_paths, paths);
char *line = NULL;
size_t size = 0;
if (!fp) {
fprintf(stderr, "failed to open `%s' for reading\n", file_paths[i]);
fclose(out);
return 1;
}
while (fline(&line, &size, fp) != -1) {
char *inc, *beg, *sep, *end, *name, *file;
FILE *f;
if (!(inc = strstr(line, "INCBIN"))) continue;
if (!(beg = strchr(inc, '('))) continue;
if (!(sep = strchr(beg, ','))) continue;
if (!(end = strchr(sep, ')'))) continue;
name = beg + 1;
file = sep + 1;
while (isspace(*name)) name++;
while (isspace(*file)) file++;
sep--;
while (isspace(*sep)) sep--;
*++sep = '\0';
end--;
while (isspace(*end)) end--;
*++end = '\0';
fprintf(out, "/* INCBIN(%s, %s); */\n", name, file);
fprintf(out, "INCBIN_CONST INCBIN_ALIGN unsigned char %s%s%s[] = {\n ", prefix, name, s(kData));
*--end = '\0';
file++;
if (!(f = open_file(file, "rb", search_paths, paths))) {
fprintf(stderr, "failed to include data `%s'\n", file);
ret = 1;
goto end;
} else {
long size, i;
unsigned char *data, count = 0;
fseek(f, 0, SEEK_END);
size = ftell(f);
fseek(f, 0, SEEK_SET);
if (!(data = (unsigned char *)malloc(size))) {
fprintf(stderr, "out of memory\n");
fclose(f);
ret = 1;
goto end;
}
if (fread(data, size, 1, f) != 1) {
fprintf(stderr, "failed reading include data `%s'\n", file);
free(data);
fclose(f);
ret = 1;
goto end;
}
for (i = 0; i < size; i++) {
if (count == 12) {
fprintf(out, "\n ");
count = 0;
}
fprintf(out, i != size - 1 ? "0x%02X, " : "0x%02X", data[i]);
count++;
}
free(data);
fclose(f);
}
fprintf(out, "\n};\n");
fprintf(out, "INCBIN_CONST INCBIN_ALIGN unsigned char *const %s%s%s = %s%s%s + sizeof(%s%s%s);\n", prefix, name, s(kEnd), prefix, name, s(kData), prefix, name, s(kData));
fprintf(out, "INCBIN_CONST unsigned int %s%s%s = sizeof(%s%s%s);\n", prefix, name, s(kSize), prefix, name, s(kData));
}
end:
free(line);
fclose(fp);
printf("included `%s'\n", file_paths[i]);
}
if (ret == 0) {
fprintf(out, "\n#ifdef __cplusplus\n");
fprintf(out, "}\n");
fprintf(out, "#endif\n");
fclose(out);
printf("generated `%s'\n", outfile);
return 0;
}
fclose(out);
remove(outfile);
return 1;
}
+479
View File
@@ -0,0 +1,479 @@
/**
* @file incbin.h
* @author Dale Weiler
* @brief Utility for including binary files
*
* Facilities for including binary files into the current translation unit and
* making use from them externally in other translation units.
*/
#ifndef INCBIN_HDR
#define INCBIN_HDR
#include <limits.h>
#if defined(__AVX512BW__) || \
defined(__AVX512CD__) || \
defined(__AVX512DQ__) || \
defined(__AVX512ER__) || \
defined(__AVX512PF__) || \
defined(__AVX512VL__) || \
defined(__AVX512F__)
# define INCBIN_ALIGNMENT_INDEX 6
#elif defined(__AVX__) || \
defined(__AVX2__)
# define INCBIN_ALIGNMENT_INDEX 5
#elif defined(__SSE__) || \
defined(__SSE2__) || \
defined(__SSE3__) || \
defined(__SSSE3__) || \
defined(__SSE4_1__) || \
defined(__SSE4_2__) || \
defined(__neon__) || \
defined(__ARM_NEON) || \
defined(__ALTIVEC__)
# define INCBIN_ALIGNMENT_INDEX 4
#elif ULONG_MAX != 0xffffffffu
# define INCBIN_ALIGNMENT_INDEX 3
# else
# define INCBIN_ALIGNMENT_INDEX 2
#endif
/* Lookup table of (1 << n) where `n' is `INCBIN_ALIGNMENT_INDEX' */
#define INCBIN_ALIGN_SHIFT_0 1
#define INCBIN_ALIGN_SHIFT_1 2
#define INCBIN_ALIGN_SHIFT_2 4
#define INCBIN_ALIGN_SHIFT_3 8
#define INCBIN_ALIGN_SHIFT_4 16
#define INCBIN_ALIGN_SHIFT_5 32
#define INCBIN_ALIGN_SHIFT_6 64
/* Actual alignment value */
#define INCBIN_ALIGNMENT \
INCBIN_CONCATENATE( \
INCBIN_CONCATENATE(INCBIN_ALIGN_SHIFT, _), \
INCBIN_ALIGNMENT_INDEX)
/* Stringize */
#define INCBIN_STR(X) \
#X
#define INCBIN_STRINGIZE(X) \
INCBIN_STR(X)
/* Concatenate */
#define INCBIN_CAT(X, Y) \
X ## Y
#define INCBIN_CONCATENATE(X, Y) \
INCBIN_CAT(X, Y)
/* Deferred macro expansion */
#define INCBIN_EVAL(X) \
X
#define INCBIN_INVOKE(N, ...) \
INCBIN_EVAL(N(__VA_ARGS__))
/* Variable argument count for overloading by arity */
#define INCBIN_VA_ARG_COUNTER(_1, _2, _3, N, ...) N
#define INCBIN_VA_ARGC(...) INCBIN_VA_ARG_COUNTER(__VA_ARGS__, 3, 2, 1, 0)
/* Green Hills uses a different directive for including binary data */
#if defined(__ghs__)
# if (__ghs_asm == 2)
# define INCBIN_MACRO ".file"
/* Or consider the ".myrawdata" entry in the ld file */
# else
# define INCBIN_MACRO "\tINCBIN"
# endif
#else
# define INCBIN_MACRO ".incbin"
#endif
#ifndef _MSC_VER
# define INCBIN_ALIGN \
__attribute__((aligned(INCBIN_ALIGNMENT)))
#else
# define INCBIN_ALIGN __declspec(align(INCBIN_ALIGNMENT))
#endif
#if defined(__arm__) || /* GNU C and RealView */ \
defined(__arm) || /* Diab */ \
defined(_ARM) /* ImageCraft */
# define INCBIN_ARM
#endif
#ifdef __GNUC__
/* Utilize .balign where supported */
# define INCBIN_ALIGN_HOST ".balign " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
# define INCBIN_ALIGN_BYTE ".balign 1\n"
#elif defined(INCBIN_ARM)
/*
* On arm assemblers, the alignment value is calculated as (1 << n) where `n' is
* the shift count. This is the value passed to `.align'
*/
# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT_INDEX) "\n"
# define INCBIN_ALIGN_BYTE ".align 0\n"
#else
/* We assume other inline assembler's treat `.align' as `.balign' */
# define INCBIN_ALIGN_HOST ".align " INCBIN_STRINGIZE(INCBIN_ALIGNMENT) "\n"
# define INCBIN_ALIGN_BYTE ".align 1\n"
#endif
/* INCBIN_CONST is used by incbin.c generated files */
#if defined(__cplusplus)
# define INCBIN_EXTERNAL extern "C"
# define INCBIN_CONST extern const
#else
# define INCBIN_EXTERNAL extern
# define INCBIN_CONST const
#endif
/**
* @brief Optionally override the linker section into which size and data is
* emitted.
*
* @warning If you use this facility, you might have to deal with
* platform-specific linker output section naming on your own.
*/
#if !defined(INCBIN_OUTPUT_SECTION)
# if defined(__APPLE__)
# define INCBIN_OUTPUT_SECTION ".const_data"
# else
# define INCBIN_OUTPUT_SECTION ".rodata"
# endif
#endif
/**
* @brief Optionally override the linker section into which data is emitted.
*
* @warning If you use this facility, you might have to deal with
* platform-specific linker output section naming on your own.
*/
#if !defined(INCBIN_OUTPUT_DATA_SECTION)
# define INCBIN_OUTPUT_DATA_SECTION INCBIN_OUTPUT_SECTION
#endif
/**
* @brief Optionally override the linker section into which size is emitted.
*
* @warning If you use this facility, you might have to deal with
* platform-specific linker output section naming on your own.
*
* @note This is useful for Harvard architectures where program memory cannot
* be directly read from the program without special instructions. With this you
* can chose to put the size variable in RAM rather than ROM.
*/
#if !defined(INCBIN_OUTPUT_SIZE_SECTION)
# define INCBIN_OUTPUT_SIZE_SECTION INCBIN_OUTPUT_SECTION
#endif
#if defined(__APPLE__)
# include "TargetConditionals.h"
# if defined(TARGET_OS_IPHONE) && !defined(INCBIN_SILENCE_BITCODE_WARNING)
# warning "incbin is incompatible with bitcode. Using the library will break upload to App Store if you have bitcode enabled. Add `#define INCBIN_SILENCE_BITCODE_WARNING` before including this header to silence this warning."
# endif
/* The directives are different for Apple branded compilers */
# define INCBIN_SECTION INCBIN_OUTPUT_SECTION "\n"
# define INCBIN_GLOBAL(NAME) ".globl " INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
# define INCBIN_INT ".long "
# define INCBIN_MANGLE "_"
# define INCBIN_BYTE ".byte "
# define INCBIN_TYPE(...)
#else
# define INCBIN_SECTION ".section " INCBIN_OUTPUT_SECTION "\n"
# define INCBIN_GLOBAL(NAME) ".global " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME "\n"
# if defined(__ghs__)
# define INCBIN_INT ".word "
# else
# define INCBIN_INT ".int "
# endif
# if defined(__USER_LABEL_PREFIX__)
# define INCBIN_MANGLE INCBIN_STRINGIZE(__USER_LABEL_PREFIX__)
# else
# define INCBIN_MANGLE ""
# endif
# if defined(INCBIN_ARM)
/* On arm assemblers, `@' is used as a line comment token */
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", %object\n"
# elif defined(__MINGW32__) || defined(__MINGW64__)
/* Mingw doesn't support this directive either */
# define INCBIN_TYPE(NAME)
# elif defined(_WIN32)
// CIEKCE: this just doesn't work on windows at all
# define INCBIN_TYPE(NAME)
# else
/* It's safe to use `@' on other architectures */
# define INCBIN_TYPE(NAME) ".type " INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME ", @object\n"
# endif
# define INCBIN_BYTE ".byte "
#endif
/* List of style types used for symbol names */
#define INCBIN_STYLE_CAMEL 0
#define INCBIN_STYLE_SNAKE 1
/**
* @brief Specify the prefix to use for symbol names.
*
* @note By default this is "g".
*
* @code
* #define INCBIN_PREFIX incbin
* #include "incbin.h"
* INCBIN(Foo, "foo.txt");
*
* // Now you have the following symbols instead:
* // const unsigned char incbinFoo<data>[];
* // const unsigned char *const incbinFoo<end>;
* // const unsigned int incbinFoo<size>;
* @endcode
*/
#if !defined(INCBIN_PREFIX)
# define INCBIN_PREFIX g
#endif
/**
* @brief Specify the style used for symbol names.
*
* Possible options are
* - INCBIN_STYLE_CAMEL "CamelCase"
* - INCBIN_STYLE_SNAKE "snake_case"
*
* @note By default this is INCBIN_STYLE_CAMEL
*
* @code
* #define INCBIN_STYLE INCBIN_STYLE_SNAKE
* #include "incbin.h"
* INCBIN(foo, "foo.txt");
*
* // Now you have the following symbols:
* // const unsigned char <prefix>foo_data[];
* // const unsigned char *const <prefix>foo_end;
* // const unsigned int <prefix>foo_size;
* @endcode
*/
#if !defined(INCBIN_STYLE)
# define INCBIN_STYLE INCBIN_STYLE_CAMEL
#endif
/* Style lookup tables */
#define INCBIN_STYLE_0_DATA Data
#define INCBIN_STYLE_0_END End
#define INCBIN_STYLE_0_SIZE Size
#define INCBIN_STYLE_1_DATA _data
#define INCBIN_STYLE_1_END _end
#define INCBIN_STYLE_1_SIZE _size
/* Style lookup: returning identifier */
#define INCBIN_STYLE_IDENT(TYPE) \
INCBIN_CONCATENATE( \
INCBIN_STYLE_, \
INCBIN_CONCATENATE( \
INCBIN_EVAL(INCBIN_STYLE), \
INCBIN_CONCATENATE(_, TYPE)))
/* Style lookup: returning string literal */
#define INCBIN_STYLE_STRING(TYPE) \
INCBIN_STRINGIZE( \
INCBIN_STYLE_IDENT(TYPE)) \
/* Generate the global labels by indirectly invoking the macro with our style
* type and concatenating the name against them. */
#define INCBIN_GLOBAL_LABELS(NAME, TYPE) \
INCBIN_INVOKE( \
INCBIN_GLOBAL, \
INCBIN_CONCATENATE( \
NAME, \
INCBIN_INVOKE( \
INCBIN_STYLE_IDENT, \
TYPE))) \
INCBIN_INVOKE( \
INCBIN_TYPE, \
INCBIN_CONCATENATE( \
NAME, \
INCBIN_INVOKE( \
INCBIN_STYLE_IDENT, \
TYPE)))
/**
* @brief Externally reference binary data included in another translation unit.
*
* Produces three external symbols that reference the binary data included in
* another translation unit.
*
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
* "Data", as well as "End" and "Size" after. An example is provided below.
*
* @param TYPE Optional array type. Omitting this picks a default of `unsigned char`.
* @param NAME The name given for the binary data
*
* @code
* INCBIN_EXTERN(Foo);
*
* // Now you have the following symbols:
* // extern const unsigned char <prefix>Foo<data>[];
* // extern const unsigned char *const <prefix>Foo<end>;
* // extern const unsigned int <prefix>Foo<size>;
* @endcode
*
* You may specify a custom optional data type as well as the first argument.
* @code
* INCBIN_EXTERN(custom_type, Foo);
*
* // Now you have the following symbols:
* // extern const custom_type <prefix>Foo<data>[];
* // extern const custom_type *const <prefix>Foo<end>;
* // extern const unsigned int <prefix>Foo<size>;
* @endcode
*/
#define INCBIN_EXTERN(...) \
INCBIN_CONCATENATE(INCBIN_EXTERN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
#define INCBIN_EXTERN_1(NAME, ...) \
INCBIN_EXTERN_2(unsigned char, NAME)
#define INCBIN_EXTERN_2(TYPE, NAME) \
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE \
INCBIN_CONCATENATE( \
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
INCBIN_STYLE_IDENT(DATA))[]; \
INCBIN_EXTERNAL const INCBIN_ALIGN TYPE *const \
INCBIN_CONCATENATE( \
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
INCBIN_STYLE_IDENT(END)); \
INCBIN_EXTERNAL const unsigned int \
INCBIN_CONCATENATE( \
INCBIN_CONCATENATE(INCBIN_PREFIX, NAME), \
INCBIN_STYLE_IDENT(SIZE))
/**
* @brief Externally reference textual data included in another translation unit.
*
* Produces three external symbols that reference the textual data included in
* another translation unit.
*
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
* "Data", as well as "End" and "Size" after. An example is provided below.
*
* @param NAME The name given for the textual data
*
* @code
* INCBIN_EXTERN(Foo);
*
* // Now you have the following symbols:
* // extern const char <prefix>Foo<data>[];
* // extern const char *const <prefix>Foo<end>;
* // extern const unsigned int <prefix>Foo<size>;
* @endcode
*/
#define INCTXT_EXTERN(NAME) \
INCBIN_EXTERN_2(char, NAME)
/**
* @brief Include a binary file into the current translation unit.
*
* Includes a binary file into the current translation unit, producing three symbols
* for objects that encode the data and size respectively.
*
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
* "Data", as well as "End" and "Size" after. An example is provided below.
*
* @param TYPE Optional array type. Omitting this picks a default of `unsigned char`.
* @param NAME The name to associate with this binary data (as an identifier.)
* @param FILENAME The file to include (as a string literal.)
*
* @code
* INCBIN(Icon, "icon.png");
*
* // Now you have the following symbols:
* // const unsigned char <prefix>Icon<data>[];
* // const unsigned char *const <prefix>Icon<end>;
* // const unsigned int <prefix>Icon<size>;
* @endcode
*
* You may specify a custom optional data type as well as the first argument.
* These macros are specialized by arity.
* @code
* INCBIN(custom_type, Icon, "icon.png");
*
* // Now you have the following symbols:
* // const custom_type <prefix>Icon<data>[];
* // const custom_type *const <prefix>Icon<end>;
* // const unsigned int <prefix>Icon<size>;
* @endcode
*
* @warning This must be used in global scope
* @warning The identifiers may be different if INCBIN_STYLE is not default
*
* To externally reference the data included by this in another translation unit
* please @see INCBIN_EXTERN.
*/
#ifdef _MSC_VER
# define INCBIN(NAME, FILENAME) \
INCBIN_EXTERN(NAME)
#else
# define INCBIN(...) \
INCBIN_CONCATENATE(INCBIN_, INCBIN_VA_ARGC(__VA_ARGS__))(__VA_ARGS__)
# if defined(__GNUC__)
# define INCBIN_1(...) _Pragma("GCC error \"Single argument INCBIN not allowed\"")
# elif defined(__clang__)
# define INCBIN_1(...) _Pragma("clang error \"Single argument INCBIN not allowed\"")
# else
# define INCBIN_1(...) /* Cannot do anything here */
# endif
# define INCBIN_2(NAME, FILENAME) \
INCBIN_3(unsigned char, NAME, FILENAME)
# define INCBIN_3(TYPE, NAME, FILENAME) INCBIN_COMMON(TYPE, NAME, FILENAME, /* No terminator for binary data */)
# define INCBIN_COMMON(TYPE, NAME, FILENAME, TERMINATOR) \
__asm__(INCBIN_SECTION \
INCBIN_GLOBAL_LABELS(NAME, DATA) \
INCBIN_ALIGN_HOST \
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) ":\n" \
INCBIN_MACRO " \"" FILENAME "\"\n" \
TERMINATOR \
INCBIN_GLOBAL_LABELS(NAME, END) \
INCBIN_ALIGN_BYTE \
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) ":\n" \
INCBIN_BYTE "1\n" \
INCBIN_GLOBAL_LABELS(NAME, SIZE) \
INCBIN_ALIGN_HOST \
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \
INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \
INCBIN_ALIGN_HOST \
".text\n" \
); \
INCBIN_EXTERN(TYPE, NAME)
#endif
/**
* @brief Include a textual file into the current translation unit.
*
* This behaves the same as INCBIN except it produces char compatible arrays
* and implicitly adds a null-terminator byte, thus the size of data included
* by this is one byte larger than that of INCBIN.
*
* Includes a textual file into the current translation unit, producing three
* symbols for objects that encode the data and size respectively.
*
* The symbol names are a concatenation of `INCBIN_PREFIX' before *NAME*; with
* "Data", as well as "End" and "Size" after. An example is provided below.
*
* @param NAME The name to associate with this binary data (as an identifier.)
* @param FILENAME The file to include (as a string literal.)
*
* @code
* INCTXT(Readme, "readme.txt");
*
* // Now you have the following symbols:
* // const char <prefix>Readme<data>[];
* // const char *const <prefix>Readme<end>;
* // const unsigned int <prefix>Readme<size>;
* @endcode
*
* @warning This must be used in global scope
* @warning The identifiers may be different if INCBIN_STYLE is not default
*
* To externally reference the data included by this in another translation unit
* please @see INCBIN_EXTERN.
*/
#if defined(_MSC_VER)
# define INCTXT(NAME, FILENAME) \
INCBIN_EXTERN(NAME)
#else
# define INCTXT(NAME, FILENAME) \
INCBIN_COMMON(char, NAME, FILENAME, INCBIN_BYTE "0\n")
#endif
#endif
BIN
View File
Binary file not shown.
+86
View File
@@ -0,0 +1,86 @@
#include "accumulator.h"
#include "types.h"
#include "bitboard.h"
namespace ACC {
int CalculateIndex(bool perspective, bool side, int pieceType, int square) {
if (perspective == Black)
{
side = 1 - side; // Flip side
square = square ^ 0b111000; // Mirror square
}
return side * 64 * 6 + pieceType * 64 + square;
}
// All friendly, for quiets
void AccumulatorPair::addSub(bool stm, int add, int addPT, int sub, int subPT) {
int addW = CalculateIndex(White, stm, addPT, add);
int addB = CalculateIndex(Black, stm, addPT, add);
int subW = CalculateIndex(White, stm, subPT, sub);
int subB = CalculateIndex(Black, stm, subPT, sub);
for (int i = 0; i < NNUE::HL_SIZE; i++) {
white.values[i] += NNUE::net.accumulator_weights[addW * NNUE::HL_SIZE + i];
black.values[i] += NNUE::net.accumulator_weights[addB * NNUE::HL_SIZE + i];
white.values[i] -= NNUE::net.accumulator_weights[subW * NNUE::HL_SIZE + i];
black.values[i] -= NNUE::net.accumulator_weights[subB * NNUE::HL_SIZE + i];
}
}
// Captures
void AccumulatorPair::addSubSub(bool stm, int add, int addPT, int sub1, int subPT1, int sub2, int subPT2) {
int addW = CalculateIndex(White, stm, addPT, add);
int addB = CalculateIndex(Black, stm, addPT, add);
int subW1 = CalculateIndex(White, stm, subPT1, sub1);
int subB1 = CalculateIndex(Black, stm, subPT1, sub1);
int subW2 = CalculateIndex(White, !stm, subPT2, sub2);
int subB2 = CalculateIndex(Black, !stm, subPT2, sub2);
for (int i = 0; i < NNUE::HL_SIZE; i++) {
white.values[i] += NNUE::net.accumulator_weights[addW * NNUE::HL_SIZE + i];
black.values[i] += NNUE::net.accumulator_weights[addB * NNUE::HL_SIZE + i];
white.values[i] -= NNUE::net.accumulator_weights[subW1 * NNUE::HL_SIZE + i];
black.values[i] -= NNUE::net.accumulator_weights[subB1 * NNUE::HL_SIZE + i];
white.values[i] -= NNUE::net.accumulator_weights[subW2 * NNUE::HL_SIZE + i];
black.values[i] -= NNUE::net.accumulator_weights[subB2 * NNUE::HL_SIZE + i];
}
}
// Castling
void AccumulatorPair::addAddSubSub(bool stm, int add1, int addPT1, int add2, int addPT2, int sub1, int subPT1, int sub2, int subPT2) {
int addW1 = CalculateIndex(White, stm, addPT1, add1);
int addB1 = CalculateIndex(Black, stm, addPT1, add1);
int addW2 = CalculateIndex(White, stm, addPT2, add2);
int addB2 = CalculateIndex(Black, stm, addPT2, add2);
int subW1 = CalculateIndex(White, stm, subPT1, sub1);
int subB1 = CalculateIndex(Black, stm, subPT1, sub1);
int subW2 = CalculateIndex(White, stm, subPT2, sub2);
int subB2 = CalculateIndex(Black, stm, subPT2, sub2);
for (int i = 0; i < NNUE::HL_SIZE; i++) {
white.values[i] += NNUE::net.accumulator_weights[addW1 * NNUE::HL_SIZE + i];
black.values[i] += NNUE::net.accumulator_weights[addB1 * NNUE::HL_SIZE + i];
white.values[i] += NNUE::net.accumulator_weights[addW2 * NNUE::HL_SIZE + i];
black.values[i] += NNUE::net.accumulator_weights[addB2 * NNUE::HL_SIZE + i];
white.values[i] -= NNUE::net.accumulator_weights[subW1 * NNUE::HL_SIZE + i];
black.values[i] -= NNUE::net.accumulator_weights[subB1 * NNUE::HL_SIZE + i];
white.values[i] -= NNUE::net.accumulator_weights[subW2 * NNUE::HL_SIZE + i];
black.values[i] -= NNUE::net.accumulator_weights[subB2 * NNUE::HL_SIZE + i];
}
}
}
+22
View File
@@ -0,0 +1,22 @@
#pragma once
#include "nnue.h"
namespace ACC {
struct Accumulator {
alignas(32) std::array<int16_t, NNUE::HL_SIZE> values;
};
struct AccumulatorPair {
alignas(32) Accumulator white;
alignas(32) Accumulator black;
// yoinked from Quinniboi - Prelude
void addSub(bool stm, int add, int addPT, int sub, int subPT);
void addSubSub(bool stm, int add, int addPT, int sub1, int subPT1, int sub2, int subPT2);
void addAddSubSub(bool stm, int add1, int addPT1, int add2, int addPT2, int sub1, int subPT1, int sub2, int subPT2);
};
int CalculateIndex(bool perspective, bool side, int pieceType, int square);
}
+91 -26
View File
@@ -19,6 +19,8 @@ void Board::Reset() {
pieces = std::array<Bitboard, 6>();
colors = std::array<Bitboard, 2>();
accPair = ACC::AccumulatorPair();
pieceThreats = std::array<Bitboard, 6>();
colorThreats = std::array<Bitboard, 2>();
@@ -79,6 +81,7 @@ void Board::SetByFen(std::string_view fen) {
hashKey = UTILS::GetHashKey(*this);
MOVEGEN::GenThreatMaps(*this);
MOVEGEN::GenerateMoves<All>(*this);
ResetAccPair();
}
void Board::PrintBoard() {
@@ -133,6 +136,30 @@ void Board::PrintBoard() {
std::cout << " Hashkey: 0x" << std::hex << hashKey << std::dec << std::endl;
}
void Board::PrintNNUE() {
std::cout << "First 16 HL biases: ";
for (int i = 0; i < 16; i++) {
std::cout << NNUE::net.accumulator_biases[i] << ' ';
}
std::cout << std::endl;
std::cout << "Output neuron bias: " << NNUE::net.output_bias << std::endl;
std::cout << "First 16 accumulator values (pre-activation)[white] ";
for (int i = 0; i < 16; i++) {
if (accPair.white.values[i] != 0) {
std::cout << accPair.white.values[i] << ' ';
}
}
std::cout << std::endl;
std::cout << "Final eval: " << NNUE::net.Evaluate(*this) << std::endl;
}
void Board::AddMove(Move move) {
moveList[currentMoveIndex] = move;
currentMoveIndex++;
@@ -251,9 +278,33 @@ bool Board::MakeMove(Move move) {
int targetPiece = GetPieceType(move.MoveTo());
int direction = attackerColor ? south : north;
int endPiece = attackerPiece;
// Removing attacker piece from old position
RemovePiece(attackerPiece, move.MoveFrom(), attackerColor);
if (move.IsPromo()) {
if (move.IsCapture()) {
endPiece = move.GetFlags() - 9;
Promote(move.MoveTo(), endPiece, sideToMove, true);
} else {
endPiece = move.GetFlags() - 5;
Promote(move.MoveTo(), endPiece, sideToMove, false);
}
}
if (move.IsCapture()) {
if (move.GetFlags() != epCapture) {
accPair.addSubSub(sideToMove, move.MoveTo(), endPiece, move.MoveFrom(), attackerPiece, move.MoveTo(), targetPiece);
} else {
accPair.addSubSub(sideToMove, enPassantTarget, endPiece, move.MoveFrom(), attackerPiece, move.MoveTo() - direction, Pawn);
}
} else {
if (move.GetFlags() != kingCastle && move.GetFlags() != queenCastle) {
accPair.addSub(sideToMove, move.MoveTo(), endPiece, move.MoveFrom(), attackerPiece);
}
}
switch (move.GetFlags())
{
case quiet:
@@ -285,6 +336,8 @@ bool Board::MakeMove(Move move) {
SetPiece(Rook, rookSquare - 2, attackerColor);
SetPiece(attackerPiece, move.MoveTo(), attackerColor);
accPair.addAddSubSub(sideToMove, move.MoveTo(), King, rookSquare - 2, Rook, move.MoveFrom(), King, rookSquare, Rook);
break;
}
case queenCastle:
@@ -298,32 +351,9 @@ bool Board::MakeMove(Move move) {
SetPiece(Rook, rookSquare + 3, attackerColor);
SetPiece(attackerPiece, move.MoveTo(), attackerColor);
accPair.addAddSubSub(sideToMove, move.MoveTo(), King, rookSquare + 3, Rook, move.MoveFrom(), King, rookSquare, Rook);
break;
}
case knightPromotion:
Promote(move.MoveTo(), Knight, attackerColor, false);
break;
case bishopPromotion:
Promote(move.MoveTo(), Bishop, attackerColor, false);
break;
case rookPromotion:
Promote(move.MoveTo(), Rook, attackerColor, false);
break;
case queenPromotion:
Promote(move.MoveTo(), Queen, attackerColor, false);
break;
case knightPromoCapture:
Promote(move.MoveTo(), Knight, attackerColor, true);
break;
case bishopPromoCapture:
Promote(move.MoveTo(), Bishop, attackerColor, true);
break;
case rookPromoCapture:
Promote(move.MoveTo(), Rook, attackerColor, true);
break;
case queenPromoCapture:
Promote(move.MoveTo(), Queen, attackerColor, true);
break;
default:
break;
}
@@ -343,7 +373,6 @@ bool Board::MakeMove(Move move) {
}
enPassantTarget = newEpTarget;
MOVEGEN::GenThreatMaps(*this);
@@ -360,7 +389,7 @@ bool Board::MakeMove(Move move) {
} else {
halfMoves++;
}
positionIndex++;
positionHistory[positionIndex] = hashKey;
@@ -378,3 +407,39 @@ bool Board::InPossibleZug() {
return !toCheck;
}
void Board::ResetAccPair() {
Bitboard whitePieces = colors[White];
Bitboard blackPieces = colors[Black];
accPair.white.values = NNUE::net.accumulator_biases;
accPair.black.values = NNUE::net.accumulator_biases;
while (whitePieces) {
int square = whitePieces.getLS1BIndex();
int wInput = ACC::CalculateIndex(White, White, GetPieceType(square), square);
int bInput = ACC::CalculateIndex(Black, White, GetPieceType(square), square);
for (int i = 0; i < NNUE::HL_SIZE; i++) {
accPair.white.values[i] += NNUE::net.accumulator_weights[wInput * NNUE::HL_SIZE + i];
accPair.black.values[i] += NNUE::net.accumulator_weights[bInput * NNUE::HL_SIZE + i];
}
whitePieces.PopBit(square);
}
while (blackPieces) {
int square = blackPieces.getLS1BIndex();
int wInput = ACC::CalculateIndex(White, Black, GetPieceType(square), square);
int bInput = ACC::CalculateIndex(Black, Black, GetPieceType(square), square);
for (int i = 0; i < NNUE::HL_SIZE; i++) {
accPair.white.values[i] += NNUE::net.accumulator_weights[wInput * NNUE::HL_SIZE + i];
accPair.black.values[i] += NNUE::net.accumulator_weights[bInput * NNUE::HL_SIZE + i];
}
blackPieces.PopBit(square);
}
}
+7 -1
View File
@@ -3,6 +3,7 @@
#include "bitboard.h"
#include "types.h"
#include "move.h"
#include "accumulator.h"
constexpr int nullPieceType = 100;
constexpr int noEPTarget = -1;
@@ -23,6 +24,8 @@ public:
Bitboard occupied;
ACC::AccumulatorPair accPair;
std::array<Bitboard, 6> pieceThreats;
std::array<Bitboard, 2> colorThreats;
@@ -39,15 +42,18 @@ public:
U64 hashKey = 0ULL;
void Init();
void Reset();
void SetByFen(std::string_view fen);
void PrintBoard();
void PrintNNUE();
void AddMove(Move move);
void ResetMoves();
void ListMoves();
void ResetAccPair();
int GetPieceType(int square);
int GetPieceColor(int square);
+36
View File
@@ -5,8 +5,44 @@
#include "benchmark.h"
#include "search.h"
#include "datagen.h"
#include "nnue.h"
#ifndef EVALFILE
#define EVALFILE "./nnue.bin"
#endif
#ifdef _MSC_VER
#define MSVC
#pragma push_macro("_MSC_VER")
#undef _MSC_VER
#endif
#include "../external/incbin.h"
#ifdef MSVC
#pragma pop_macro("_MSC_VER")
#undef MSVC
#endif
#if !defined(_MSC_VER) || defined(__clang__)
INCBIN(EVAL, EVALFILE);
#endif
int main(int argc, char* argv[]) {
auto loadDefaultNet = [&]([[maybe_unused]] bool warnMSVC = false) {
#if defined(_MSC_VER) && !defined(__clang__)
NNUE::net.Load(EVALFILE);
if (warnMSVC)
cerr << "WARNING: This file was compiled with MSVC, this means that an nnue was NOT embedded into the exe." << endl;
#else
NNUE::net = *reinterpret_cast<const NNUE::Network*>(gEVALData);
#endif
};
loadDefaultNet(true);
MOVEGEN::initLeaperAttacks();
MOVEGEN::initSliderAttacks();
UTILS::InitZobrist();
+4
View File
@@ -60,6 +60,10 @@ public:
|| GetFlags() == queenCastle || GetFlags() == doublePawnPush);
}
bool IsPromo() {
return (GetFlags() >= knightPromotion);
}
void PrintMove() {
std::cout << squareCoords[MoveFrom()] << squareCoords[MoveTo()];
+83
View File
@@ -0,0 +1,83 @@
#include <immintrin.h>
#include <fstream>
#include <algorithm>
#include "nnue.h"
#include "accumulator.h"
#include "board.h"
#include "types.h"
#include "search.h"
namespace NNUE {
void Network::Load(const std::string& path) {
std::ifstream file(path, std::ios::binary);
if (!file.is_open()){
std::cerr << "Failed to open file " + path << std::endl;
}
// HL weights
for (int i = 0; i < accumulator_weights.size(); i++) {
file.read(reinterpret_cast<char*>(&accumulator_weights[i]), sizeof(int16_t));
}
// HL biases
for (int i = 0; i < accumulator_biases.size(); i++) {
file.read(reinterpret_cast<char*>(&accumulator_biases[i]), sizeof(int16_t));
}
// Output weights
for (int i = 0; i < output_weights.size(); i++) {
file.read(reinterpret_cast<char*>(&output_weights[i]), sizeof(int16_t));
}
// Output bias
file.read(reinterpret_cast<char*>(&output_bias), sizeof(int16_t));
}
static int32_t Forward(const Board& board,
const Network* net) {
const ACC::Accumulator& stmAcc = board.sideToMove == White ? board.accPair.white : board.accPair.black;
const ACC::Accumulator& nstmAcc = !board.sideToMove == White ? board.accPair.white : board.accPair.black;
int32_t eval = 0;
const __m256i vec_zero = _mm256_setzero_si256();
const __m256i vec_qa = _mm256_set1_epi16(QA);
__m256i sum = vec_zero;
for (int i = 0; i < HL_SIZE / 16; i++) {
const __m256i us = _mm256_load_si256(reinterpret_cast<const __m256i*>(&stmAcc.values[16 * i])); // Load from accumulator
const __m256i them = _mm256_load_si256(reinterpret_cast<const __m256i*>(&nstmAcc.values[16 * i]));
const __m256i us_weights = _mm256_load_si256(reinterpret_cast<const __m256i*>(&net->output_weights[16 * i])); // Load from net
const __m256i them_weights = _mm256_load_si256(reinterpret_cast<const __m256i*>(&net->output_weights[HL_SIZE + 16 * i]));
const __m256i us_clamped = _mm256_min_epi16(_mm256_max_epi16(us, vec_zero), vec_qa);
const __m256i them_clamped = _mm256_min_epi16(_mm256_max_epi16(them, vec_zero), vec_qa);
const __m256i us_results = _mm256_madd_epi16(_mm256_mullo_epi16(us_weights, us_clamped), us_clamped);
const __m256i them_results = _mm256_madd_epi16(_mm256_mullo_epi16(them_weights, them_clamped), them_clamped);
sum = _mm256_add_epi32(sum, us_results);
sum = _mm256_add_epi32(sum, them_results);
}
__m256i v1 = _mm256_hadd_epi32(sum, sum);
__m256i v2 = _mm256_hadd_epi32(v1, v1);
eval = _mm256_extract_epi32(v2, 0) + _mm256_extract_epi32(v2, 4);
eval /= QA;
eval += net->output_bias;
return (eval * SCALE) / (QA * QB);
}
int16_t Network::Evaluate(const Board& board) {
return std::clamp(Forward(board, this), (-SEARCH::MATE_SCORE + SEARCH::MAX_PLY),
(SEARCH::MATE_SCORE - SEARCH::MAX_PLY));
}
}
+32
View File
@@ -0,0 +1,32 @@
#pragma once
#include <cstdint>
#include <string>
#include <array>
#include "../external/fmt/fmt/format.h"
class Board;
namespace NNUE {
constexpr int INPUT_SIZE = 768;
constexpr int HL_SIZE = 64;
constexpr int SCALE = 400;
constexpr int QA = 255;
constexpr int QB = 64;
struct Network {
alignas(32) std::array<int16_t, HL_SIZE * INPUT_SIZE> accumulator_weights;
alignas(32) std::array<int16_t, HL_SIZE> accumulator_biases;
alignas(32) std::array<int16_t, 2 * HL_SIZE> output_weights;
int16_t output_bias;
void Load(const std::string& path);
int16_t Evaluate(const Board& board);
};
inline Network net;
}
+2 -2
View File
@@ -288,7 +288,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
// that a quiet move will help us so we skip them
int fpMargin = 100 * depth;
if (!isPV && ply && currMove.IsQuiet()
&& depth <= 5 && staticEval + fpMargin < alpha && results.score > MATE_SCORE) {
&& depth <= 5 && staticEval + fpMargin < alpha && results.score > -MATE_SCORE) {
continue;
}
@@ -364,7 +364,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta, int ply) {
if (moveSeen == 0) {
if (board.InCheck()) { // checkmate
return MATE_SCORE + ply;
return -MATE_SCORE + ply;
} else { // stalemate
return 0;
}
+1 -1
View File
@@ -14,7 +14,7 @@ enum searchMode {
nodesMode
};
constexpr int MATE_SCORE = -99000;
constexpr int MATE_SCORE = 32767;
constexpr int MAX_DEPTH = 64;
constexpr int MAX_PLY = 128;
constexpr int MAX_HISTORY = 16384;
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
#include <array>
#include <string_view>
using U64 = uint64_t;
+4
View File
@@ -193,5 +193,9 @@ void UCILoop(Board &board) {
board.ListMoves();
continue;
}
if (input.find("nnue") != std::string::npos) {
board.PrintNNUE();
}
}
}