mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-24 19:16:49 +08:00
Cleaned up source code.
This commit is contained in:
@@ -442,7 +442,7 @@ endif
|
||||
### 3.6 popcnt
|
||||
ifeq ($(popcnt),yes)
|
||||
ifeq ($(arch),$(filter $(arch),ppc64 armv8-a arm64))
|
||||
CXXFLAGS += -DUSE_POPCNT
|
||||
CXXFLAGS += -DUSE_POPCNT
|
||||
else ifeq ($(comp),icc)
|
||||
CXXFLAGS += -msse3 -DUSE_POPCNT
|
||||
else
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#if defined(EVAL_LEARN)
|
||||
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
|
||||
#include "../misc.h"
|
||||
#include "../learn/learn.h"
|
||||
|
||||
20
src/main.cpp
20
src/main.cpp
@@ -18,15 +18,6 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <filesystem>
|
||||
|
||||
#ifndef NOMINMAX
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include "bitboard.h"
|
||||
#include "endgame.h"
|
||||
#include "position.h"
|
||||
@@ -41,17 +32,6 @@ namespace PSQT {
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
// Change the current working directory to the binary directory. So that a
|
||||
// net file path can be specified with a relative path from the binary
|
||||
// directory.
|
||||
// TODO(someone): Implement the logic for other OS.
|
||||
#ifdef _WIN32
|
||||
TCHAR filename[_MAX_PATH];
|
||||
::GetModuleFileName(NULL, filename, sizeof(filename) / sizeof(filename[0]));
|
||||
std::filesystem::path current_path = filename;
|
||||
current_path.remove_filename();
|
||||
std::filesystem::current_path(current_path);
|
||||
#endif
|
||||
|
||||
std::cout << engine_info() << std::endl;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#ifndef MISC_H_INCLUDED
|
||||
#define MISC_H_INCLUDED
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
@@ -27,12 +26,8 @@
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#ifndef _MSC_VER
|
||||
#include <mm_malloc.h>
|
||||
#endif
|
||||
|
||||
#include "types.h"
|
||||
#include "thread_win32_osx.h"
|
||||
|
||||
const std::string engine_info(bool to_uci = false);
|
||||
const std::string compiler_info();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Eval::NNUE::Features {
|
||||
}
|
||||
}
|
||||
|
||||
// Get a list of indices whose values have changed from the previous one in the feature quantity
|
||||
// Get a list of indices whose values have changed from the previous one in the feature quantity
|
||||
template <typename IndexListType>
|
||||
static void CollectChangedIndices(
|
||||
const Position& pos, const TriggerEvent trigger, const Color perspective,
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Eval::NNUE::Layers {
|
||||
PreviousLayer::GetStructureString() + ")";
|
||||
}
|
||||
|
||||
// Read network parameters
|
||||
// Read network parameters
|
||||
bool ReadParameters(std::istream& stream) {
|
||||
if (!previous_layer_.ReadParameters(stream)) return false;
|
||||
stream.read(reinterpret_cast<char*>(biases_),
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Eval::NNUE::Layers {
|
||||
// Make the learning class a friend
|
||||
friend class Trainer<ClippedReLU>;
|
||||
|
||||
PreviousLayer previous_layer_;
|
||||
PreviousLayer previous_layer_;
|
||||
};
|
||||
|
||||
} // namespace Eval::NNUE::Layers
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||
Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
|
||||
|
||||
@@ -182,7 +182,7 @@ public:
|
||||
// Do not include gamePly in pack.
|
||||
void sfen_pack(PackedSfen& sfen);
|
||||
|
||||
// ª It is slow to go through sfen, so I made a function to set packed sfen directly.
|
||||
// It is slow to go through sfen, so I made a function to set packed sfen directly.
|
||||
// Equivalent to pos.set(sfen_unpack(data),si,th);.
|
||||
// If there is a problem with the passed phase and there is an error, non-zero is returned.
|
||||
// PackedSfen does not include gamePly so it cannot be restored. If you want to set it, specify it with an argument.
|
||||
|
||||
@@ -992,7 +992,11 @@ moves_loop: // When in check, search starts from here
|
||||
|
||||
ss->moveCount = ++moveCount;
|
||||
|
||||
if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000 && !Limits.silent)
|
||||
if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000
|
||||
#if defined(EVAL_LEARN)
|
||||
&& !Limits.silent
|
||||
#endif
|
||||
)
|
||||
sync_cout << "info depth " << depth
|
||||
<< " currmove " << UCI::move(move, pos.is_chess960())
|
||||
<< " currmovenumber " << moveCount + thisThread->pvIdx << sync_endl;
|
||||
@@ -2066,10 +2070,10 @@ namespace Learner
|
||||
// Increase the generation of the substitution table for this thread because it is a new search.
|
||||
//TT.new_search(th->thread_id());
|
||||
|
||||
// ↑ If you call new_search here, it may be a loss because you can't use the previous search result.
|
||||
// <EFBFBD><EFBFBD> If you call new_search here, it may be a loss because you can't use the previous search result.
|
||||
// Do not do this here, but caller should do TT.new_search(th->thread_id()) for each station ...
|
||||
|
||||
// →Because we want to avoid reaching the same final diagram, use the substitution table commonly for all threads when generating teachers.
|
||||
// <EFBFBD><EFBFBD>Because we want to avoid reaching the same final diagram, use the substitution table commonly for all threads when generating teachers.
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
@@ -2259,7 +2263,7 @@ namespace Learner
|
||||
}
|
||||
|
||||
// Pass PV_is(ok) to eliminate this PV, there may be NULL_MOVE in the middle.
|
||||
// → PV should not be NULL_MOVE because it is PV
|
||||
// <EFBFBD><EFBFBD> PV should not be NULL_MOVE because it is PV
|
||||
// MOVE_WIN has never been thrust. (For now)
|
||||
for (Move move : rootMoves[0].pv)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,9 @@ struct LimitsType {
|
||||
time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0);
|
||||
movestogo = depth = mate = perft = infinite = 0;
|
||||
nodes = 0;
|
||||
#if defined (EVAL_LEARN)
|
||||
silent = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool use_time_management() const {
|
||||
@@ -97,9 +99,11 @@ struct LimitsType {
|
||||
TimePoint time[COLOR_NB], inc[COLOR_NB], npmsec, movetime, startTime;
|
||||
int movestogo, depth, mate, perft, infinite;
|
||||
int64_t nodes;
|
||||
#if defined (EVAL_LEARN)
|
||||
// Silent mode that does not output to the screen (for continuous self-play in process)
|
||||
// Do not output PV at this time.
|
||||
bool silent;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern LimitsType Limits;
|
||||
|
||||
@@ -114,9 +114,6 @@ void TranspositionTable::clear() {
|
||||
/// TTEntry t2 if its replace value is greater than that of t2.
|
||||
|
||||
TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
||||
#if defined(DISABLE_TT)
|
||||
return found = false, first_entry(0);
|
||||
#else
|
||||
|
||||
TTEntry* const tte = first_entry(key);
|
||||
const uint16_t key16 = (uint16_t)key; // Use the low 16 bits as key inside the cluster
|
||||
@@ -141,7 +138,6 @@ TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
||||
replace = &tte[i];
|
||||
|
||||
return found = false, replace;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ void test_cmd(Position& pos, istringstream& is)
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
// position() is called when engine receives the "position" UCI command.
|
||||
// The function sets up the position described in the given FEN string ("fen")
|
||||
// or the starting position ("startpos") and then makes the moves given in the
|
||||
@@ -462,4 +463,4 @@ Move UCI::to_move(const Position& pos, string& str) {
|
||||
return m;
|
||||
|
||||
return MOVE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user