mirror of
https://github.com/opelly27/Stockfish.git
synced 2026-05-20 15:37:47 +00:00
Cleaned up source code.
This commit is contained in:
+1
-1
@@ -442,7 +442,7 @@ endif
|
|||||||
### 3.6 popcnt
|
### 3.6 popcnt
|
||||||
ifeq ($(popcnt),yes)
|
ifeq ($(popcnt),yes)
|
||||||
ifeq ($(arch),$(filter $(arch),ppc64 armv8-a arm64))
|
ifeq ($(arch),$(filter $(arch),ppc64 armv8-a arm64))
|
||||||
CXXFLAGS += -DUSE_POPCNT
|
CXXFLAGS += -DUSE_POPCNT
|
||||||
else ifeq ($(comp),icc)
|
else ifeq ($(comp),icc)
|
||||||
CXXFLAGS += -msse3 -DUSE_POPCNT
|
CXXFLAGS += -msse3 -DUSE_POPCNT
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#if defined(EVAL_LEARN)
|
#if defined(EVAL_LEARN)
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
#include "../misc.h"
|
#include "../misc.h"
|
||||||
#include "../learn/learn.h"
|
#include "../learn/learn.h"
|
||||||
|
|||||||
@@ -18,15 +18,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#ifndef NOMINMAX
|
|
||||||
#define NOMINMAX
|
|
||||||
#endif
|
|
||||||
#include <Windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "bitboard.h"
|
#include "bitboard.h"
|
||||||
#include "endgame.h"
|
#include "endgame.h"
|
||||||
#include "position.h"
|
#include "position.h"
|
||||||
@@ -41,17 +32,6 @@ namespace PSQT {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
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;
|
std::cout << engine_info() << std::endl;
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
#ifndef MISC_H_INCLUDED
|
#ifndef MISC_H_INCLUDED
|
||||||
#define MISC_H_INCLUDED
|
#define MISC_H_INCLUDED
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
@@ -27,12 +26,8 @@
|
|||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#ifndef _MSC_VER
|
|
||||||
#include <mm_malloc.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "thread_win32_osx.h"
|
|
||||||
|
|
||||||
const std::string engine_info(bool to_uci = false);
|
const std::string engine_info(bool to_uci = false);
|
||||||
const std::string compiler_info();
|
const std::string compiler_info();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||||
Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
|
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>
|
template <typename IndexListType>
|
||||||
static void CollectChangedIndices(
|
static void CollectChangedIndices(
|
||||||
const Position& pos, const TriggerEvent trigger, const Color perspective,
|
const Position& pos, const TriggerEvent trigger, const Color perspective,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Eval::NNUE::Layers {
|
|||||||
PreviousLayer::GetStructureString() + ")";
|
PreviousLayer::GetStructureString() + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read network parameters
|
// Read network parameters
|
||||||
bool ReadParameters(std::istream& stream) {
|
bool ReadParameters(std::istream& stream) {
|
||||||
if (!previous_layer_.ReadParameters(stream)) return false;
|
if (!previous_layer_.ReadParameters(stream)) return false;
|
||||||
stream.read(reinterpret_cast<char*>(biases_),
|
stream.read(reinterpret_cast<char*>(biases_),
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ namespace Eval::NNUE::Layers {
|
|||||||
// Make the learning class a friend
|
// Make the learning class a friend
|
||||||
friend class Trainer<ClippedReLU>;
|
friend class Trainer<ClippedReLU>;
|
||||||
|
|
||||||
PreviousLayer previous_layer_;
|
PreviousLayer previous_layer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Eval::NNUE::Layers
|
} // namespace Eval::NNUE::Layers
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
Stockfish, a UCI chess playing engine derived from Glaurung 2.1
|
||||||
Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
|
Copyright (C) 2004-2020 The Stockfish developers (see AUTHORS file)
|
||||||
|
|
||||||
@@ -182,7 +182,7 @@ public:
|
|||||||
// Do not include gamePly in pack.
|
// Do not include gamePly in pack.
|
||||||
void sfen_pack(PackedSfen& sfen);
|
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);.
|
// 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.
|
// 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.
|
// PackedSfen does not include gamePly so it cannot be restored. If you want to set it, specify it with an argument.
|
||||||
|
|||||||
+8
-4
@@ -992,7 +992,11 @@ moves_loop: // When in check, search starts from here
|
|||||||
|
|
||||||
ss->moveCount = ++moveCount;
|
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
|
sync_cout << "info depth " << depth
|
||||||
<< " currmove " << UCI::move(move, pos.is_chess960())
|
<< " currmove " << UCI::move(move, pos.is_chess960())
|
||||||
<< " currmovenumber " << moveCount + thisThread->pvIdx << sync_endl;
|
<< " 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.
|
// Increase the generation of the substitution table for this thread because it is a new search.
|
||||||
//TT.new_search(th->thread_id());
|
//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.
|
// �ª 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 ...
|
// 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.
|
// �¨Because we want to avoid reaching the same final diagram, use the substitution table commonly for all threads when generating teachers.
|
||||||
//#endif
|
//#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2259,7 +2263,7 @@ namespace Learner
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Pass PV_is(ok) to eliminate this PV, there may be NULL_MOVE in the middle.
|
// 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
|
// �¨ PV should not be NULL_MOVE because it is PV
|
||||||
// MOVE_WIN has never been thrust. (For now)
|
// MOVE_WIN has never been thrust. (For now)
|
||||||
for (Move move : rootMoves[0].pv)
|
for (Move move : rootMoves[0].pv)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -86,7 +86,9 @@ struct LimitsType {
|
|||||||
time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0);
|
time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = npmsec = movetime = TimePoint(0);
|
||||||
movestogo = depth = mate = perft = infinite = 0;
|
movestogo = depth = mate = perft = infinite = 0;
|
||||||
nodes = 0;
|
nodes = 0;
|
||||||
|
#if defined (EVAL_LEARN)
|
||||||
silent = false;
|
silent = false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool use_time_management() const {
|
bool use_time_management() const {
|
||||||
@@ -97,9 +99,11 @@ struct LimitsType {
|
|||||||
TimePoint time[COLOR_NB], inc[COLOR_NB], npmsec, movetime, startTime;
|
TimePoint time[COLOR_NB], inc[COLOR_NB], npmsec, movetime, startTime;
|
||||||
int movestogo, depth, mate, perft, infinite;
|
int movestogo, depth, mate, perft, infinite;
|
||||||
int64_t nodes;
|
int64_t nodes;
|
||||||
|
#if defined (EVAL_LEARN)
|
||||||
// Silent mode that does not output to the screen (for continuous self-play in process)
|
// Silent mode that does not output to the screen (for continuous self-play in process)
|
||||||
// Do not output PV at this time.
|
// Do not output PV at this time.
|
||||||
bool silent;
|
bool silent;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
extern LimitsType Limits;
|
extern LimitsType Limits;
|
||||||
|
|||||||
@@ -114,9 +114,6 @@ void TranspositionTable::clear() {
|
|||||||
/// TTEntry t2 if its replace value is greater than that of t2.
|
/// TTEntry t2 if its replace value is greater than that of t2.
|
||||||
|
|
||||||
TTEntry* TranspositionTable::probe(const Key key, bool& found) const {
|
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);
|
TTEntry* const tte = first_entry(key);
|
||||||
const uint16_t key16 = (uint16_t)key; // Use the low 16 bits as key inside the cluster
|
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];
|
replace = &tte[i];
|
||||||
|
|
||||||
return found = false, replace;
|
return found = false, replace;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ void test_cmd(Position& pos, istringstream& is)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// position() is called when engine receives the "position" UCI command.
|
// position() is called when engine receives the "position" UCI command.
|
||||||
// The function sets up the position described in the given FEN string ("fen")
|
// 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
|
// or the starting position ("startpos") and then makes the moves given in the
|
||||||
|
|||||||
Reference in New Issue
Block a user