// Code for calculating NNUE evaluation function
+#include "evaluate_nnue.h"
+
+#include <cmath>
+#include <cstdlib>
+#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
-#include <set>
#include <sstream>
#include <string_view>
#include "../evaluate.h"
+#include "../misc.h"
#include "../position.h"
-#include "../uci.h"
#include "../types.h"
-
-#include "evaluate_nnue.h"
+#include "../uci.h"
+#include "nnue_accumulator.h"
+#include "nnue_common.h"
namespace Stockfish::Eval::NNUE {
} // namespace Detail
+
// Initialize the evaluation function parameters
static void initialize() {
if (!Detail::write_parameters(stream, *featureTransformer)) return false;
for (std::size_t i = 0; i < LayerStacks; ++i)
if (!Detail::write_parameters(stream, *(network[i]))) return false;
- return (bool)stream;
+ return bool(stream);
}
void hint_common_parent_position(const Position& pos) {
// We manually align the arrays on the stack because with gcc < 9.3
// overaligning stack variables with alignas() doesn't work correctly.
-
constexpr uint64_t alignment = CacheLineSize;
#if defined(ALIGNAS_ON_STACK_VARIABLES_BROKEN)
}
- // format_cp_aligned_dot() converts a Value into pawns, always keeping two decimals.
+ // format_cp_aligned_dot() converts a Value into pawns, always keeping two decimals
static void format_cp_aligned_dot(Value v, std::stringstream &stream) {
+
const double pawns = std::abs(0.01 * UCI::to_cp(v));
stream << (v < 0 ? '-' : v > 0 ? '+' : ' ')
// trace() returns a string with the value of each piece on a board,
// and a table for (PSQT, Layers) values bucket by bucket.
-
std::string trace(Position& pos) {
std::stringstream ss;
// A lambda to output one box of the board
auto writeSquare = [&board](File file, Rank rank, Piece pc, Value value) {
- const int x = ((int)file) * 8;
- const int y = (7 - (int)rank) * 3;
+ const int x = int(file) * 8;
+ const int y = (7 - int(rank)) * 3;
for (int i = 1; i < 8; ++i)
board[y][x+i] = board[y+3][x+i] = '-';
for (int i = 1; i < 3; ++i)