Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
390ee23e75 | ||
|
|
4ebdeb54f6 | ||
|
|
4e437d52fc | ||
|
|
a3255581fb | ||
|
|
24a36414f8 |
No files matched your search
@@ -5,14 +5,16 @@ OBJ_DIR := obj
|
|||||||
EXE ?= Eleanor
|
EXE ?= Eleanor
|
||||||
EVALFILE := ./nnue.bin
|
EVALFILE := ./nnue.bin
|
||||||
|
|
||||||
|
CXX := clang++
|
||||||
|
|
||||||
ifeq ($(OS),Windows_NT)
|
ifeq ($(OS),Windows_NT)
|
||||||
UNAME_S := Windows
|
UNAME_S := Windows
|
||||||
|
ARCH := x86_64
|
||||||
EXE_EXT := .exe
|
EXE_EXT := .exe
|
||||||
MKDIR := mkdir
|
MKDIR := mkdir
|
||||||
RM := rmdir /s /q
|
RM := rmdir /s /q
|
||||||
DEL := del /q
|
DEL := del /q
|
||||||
PLATFORM := windows
|
PLATFORM := windows
|
||||||
CXX := g++
|
|
||||||
else
|
else
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ARCH := $(shell uname -m)
|
ARCH := $(shell uname -m)
|
||||||
@@ -20,7 +22,6 @@ else
|
|||||||
MKDIR := mkdir -p
|
MKDIR := mkdir -p
|
||||||
RM := rm -rf
|
RM := rm -rf
|
||||||
DEL := rm -f
|
DEL := rm -f
|
||||||
CXX := clang++
|
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
PLATFORM := mac
|
PLATFORM := mac
|
||||||
else
|
else
|
||||||
@@ -28,6 +29,8 @@ else
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
CXX_BASE := $(notdir $(firstword $(CXX)))
|
||||||
|
CXX_DRIVER_FLAGS :=
|
||||||
CXXFLAGS := -std=c++20 -O3 -flto -Wall
|
CXXFLAGS := -std=c++20 -O3 -flto -Wall
|
||||||
LDFLAGS := -O3 -flto
|
LDFLAGS := -O3 -flto
|
||||||
|
|
||||||
@@ -39,6 +42,9 @@ ifeq ($(PLATFORM),mac)
|
|||||||
endif
|
endif
|
||||||
else ifeq ($(PLATFORM),windows)
|
else ifeq ($(PLATFORM),windows)
|
||||||
ARCH_FLAGS := -march=native
|
ARCH_FLAGS := -march=native
|
||||||
|
CXX_DRIVER_FLAGS += --target=$(ARCH)-w64-windows-gnu
|
||||||
|
CXXFLAGS += -pthread
|
||||||
|
LDFLAGS += -pthread
|
||||||
LDFLAGS += -static -Wl,--stack,8388608
|
LDFLAGS += -static -Wl,--stack,8388608
|
||||||
else
|
else
|
||||||
ifeq ($(ARCH),aarch64)
|
ifeq ($(ARCH),aarch64)
|
||||||
@@ -58,10 +64,10 @@ SRCS := $(wildcard $(SRC_DIR)/*.cpp)
|
|||||||
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
|
OBJS := $(patsubst $(SRC_DIR)/%.cpp, $(OBJ_DIR)/%.o, $(SRCS))
|
||||||
|
|
||||||
$(EXE)$(EXE_EXT): $(OBJS)
|
$(EXE)$(EXE_EXT): $(OBJS)
|
||||||
$(CXX) $(CXXFLAGS) -DEVALFILE=\"$(EVALFILE)\" $^ -o $@ $(LDFLAGS)
|
$(CXX) $(CXX_DRIVER_FLAGS) $(CXXFLAGS) -DEVALFILE=\"$(EVALFILE)\" $^ -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp | $(OBJ_DIR)
|
||||||
$(CXX) $(CXXFLAGS) -c -o $@ $<
|
$(CXX) $(CXX_DRIVER_FLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(OBJ_DIR):
|
$(OBJ_DIR):
|
||||||
$(MKDIR) $(OBJ_DIR)
|
$(MKDIR) $(OBJ_DIR)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
| Version | Release Date | [CCRL 40/15](https://www.computerchess.org.uk/ccrl/4040/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) | [CCRL Blitz](https://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) |
|
| Version | Release Date | [CCRL 40/15](https://www.computerchess.org.uk/ccrl/4040/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) | [CCRL Blitz](https://www.computerchess.org.uk/ccrl/404/cgi/compare_engines.cgi?family=Eleanor&print=Rating+list&print=Results+table&print=LOS+table&print=Ponder+hit+table&print=Eval+difference+table&print=Comopp+gamenum+table&print=Overlap+table&print=Score+with+common+opponents) |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| 4.0 | 2026-04-18 | - | -
|
| 4.1 | 2026-04-22 | - | -
|
||||||
| 3.0 | 2025-12-05 | 3405 (#84) | 3495 (#79-80)
|
| 3.0 | 2025-12-05 | 3405 (#84) | 3495 (#79-80)
|
||||||
| 2.0 | 2025-08-23 | 3312 (#115) | 3392 (#105)
|
| 2.0 | 2025-08-23 | 3312 (#115) | 3392 (#105)
|
||||||
| 1.0 | 2025-06-02 | 2856 (#244) | 2759 (#256)
|
| 1.0 | 2025-06-02 | 2856 (#244) | 2759 (#256)
|
||||||
@@ -32,7 +32,8 @@ A 1536-hidden-layer *perspective net* with 8 input buckets, 8 output buckets and
|
|||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
> **Prerequisites:**
|
> **Prerequisites:**
|
||||||
> - `clang++` on linux, `g++` on windows
|
> - `clang++` compiler
|
||||||
|
> - On Windows, `clang++` must have access to a MinGW GNU toolchain/runtime because the build targets `x86_64-w64-windows-gnu`
|
||||||
> - Access to `make` command
|
> - Access to `make` command
|
||||||
|
|
||||||
1. Clone the repository
|
1. Clone the repository
|
||||||
|
|||||||
+15
-12
@@ -238,18 +238,18 @@ static bool ShouldStop(SearchContext* ctx) {
|
|||||||
if constexpr (mode == normal) {
|
if constexpr (mode == normal) {
|
||||||
if (ctx->nodes % 1024 == 0) {
|
if (ctx->nodes % 1024 == 0) {
|
||||||
if (ctx->sw.GetElapsedMS() >= ctx->timeToSearch) {
|
if (ctx->sw.GetElapsedMS() >= ctx->timeToSearch) {
|
||||||
searchStopped = true;
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == nodesMode) {
|
} else if constexpr (mode == nodesMode) {
|
||||||
if (ctx->nodes > ctx->nodesToGo) {
|
if (ctx->nodes > ctx->nodesToGo) {
|
||||||
searchStopped = true;
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == datagen) {
|
} else if constexpr (mode == datagen) {
|
||||||
if (ctx->nodes > DATAGEN::HARD_NODES) {
|
if (ctx->nodes > DATAGEN::HARD_NODES) {
|
||||||
searchStopped = true;
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -378,7 +378,7 @@ static SearchResults Quiescence(Board& board, int alpha, int beta, int ply, Sear
|
|||||||
}
|
}
|
||||||
|
|
||||||
results.score = bestScore;
|
results.score = bestScore;
|
||||||
if (searchStopped) return 0;
|
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
ctx->TT->WriteEntry(board.hashKey, 0, results.score, nodeType, results.bestMove, ttpv);
|
ctx->TT->WriteEntry(board.hashKey, 0, results.score, nodeType, results.bestMove, ttpv);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
@@ -474,7 +474,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
|
|
||||||
int score = -PVS<false, mode>(copy, depth - reduction, -beta, -beta + 1, ply + 1, ctx, !cutnode).score;
|
int score = -PVS<false, mode>(copy, depth - reduction, -beta, -beta + 1, ply + 1, ctx, !cutnode).score;
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
if (score >= beta) {
|
if (score >= beta) {
|
||||||
if (depth <= 14 || ctx->minNmpPly > 0) {
|
if (depth <= 14 || ctx->minNmpPly > 0) {
|
||||||
return score > MATE_SCORE - MAX_DEPTH ? beta : score;
|
return score > MATE_SCORE - MAX_DEPTH ? beta : score;
|
||||||
@@ -533,7 +533,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
ply + 1, ctx, !cutnode).score;
|
ply + 1, ctx, !cutnode).score;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
|
|
||||||
if (score >= probcutBeta) {
|
if (score >= probcutBeta) {
|
||||||
ctx->TT->WriteEntry(board.hashKey, probcutDepth, score, CutNode, currMove, ttpv);
|
ctx->TT->WriteEntry(board.hashKey, probcutDepth, score, CutNode, currMove, ttpv);
|
||||||
@@ -701,7 +701,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
ctx->nodesTable[currMove % 4096] += ctx->nodes - nodesBeforeSearch;
|
ctx->nodesTable[currMove % 4096] += ctx->nodes - nodesBeforeSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
|
|
||||||
if (currMove != 0 && currMove.IsQuiet()) {
|
if (currMove != 0 && currMove.IsQuiet()) {
|
||||||
seenQuiets[seenQuietsCount] = currMove;
|
seenQuiets[seenQuietsCount] = currMove;
|
||||||
@@ -789,7 +789,7 @@ SearchResults PVS(Board& board, int depth, int alpha, int beta, int ply, SearchC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchStopped) return 0;
|
if (searchStopped.load(std::memory_order_relaxed)) return 0;
|
||||||
if (!ctx->excluded) {
|
if (!ctx->excluded) {
|
||||||
|
|
||||||
if (!inCheck && ((results.bestMove.IsQuiet() || !results.bestMove))
|
if (!inCheck && ((results.bestMove.IsQuiet() || !results.bestMove))
|
||||||
@@ -888,7 +888,7 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
|
|||||||
|
|
||||||
aw.Set(currentResults.score);
|
aw.Set(currentResults.score);
|
||||||
|
|
||||||
if (searchStopped) {
|
if (searchStopped.load(std::memory_order_relaxed)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
if (currentResults.bestMove) {
|
if (currentResults.bestMove) {
|
||||||
@@ -901,13 +901,13 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
|
|||||||
|
|
||||||
if constexpr (mode == normal) {
|
if constexpr (mode == normal) {
|
||||||
if (ctx->sw.GetElapsedMS() >= softTime) {
|
if (ctx->sw.GetElapsedMS() >= softTime) {
|
||||||
searchStopped = true;
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if constexpr (mode == datagen) {
|
} else if constexpr (mode == datagen) {
|
||||||
if (ctx->nodes >= DATAGEN::SOFT_NODES) {
|
if (ctx->nodes >= DATAGEN::SOFT_NODES) {
|
||||||
searchStopped = true;
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -919,8 +919,11 @@ static SearchResults ID(Board &board, SearchParams params, SearchContext* ctx) {
|
|||||||
|
|
||||||
template <searchMode mode>
|
template <searchMode mode>
|
||||||
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* ctx) {
|
SearchResults SearchPosition(Board &board, SearchParams params, SearchContext* ctx) {
|
||||||
searchStopped = false;
|
if constexpr (mode == bench || mode == datagen) {
|
||||||
|
searchStopped.store(false, std::memory_order_relaxed);
|
||||||
ctx->TT->IncreaseAge();
|
ctx->TT->IncreaseAge();
|
||||||
|
}
|
||||||
|
|
||||||
ctx->seldepth = 0;
|
ctx->seldepth = 0;
|
||||||
ctx->nodesTable = {};
|
ctx->nodesTable = {};
|
||||||
if constexpr (mode != bench) {
|
if constexpr (mode != bench) {
|
||||||
|
|||||||
+2
-4
@@ -67,13 +67,11 @@ public:
|
|||||||
TTable() : table(defaultHash) {};
|
TTable() : table(defaultHash) {};
|
||||||
|
|
||||||
void Resize(U64 size) {
|
void Resize(U64 size) {
|
||||||
table.resize(size);
|
table.assign(size, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() {
|
||||||
U64 size = table.size();
|
std::fill(table.begin(), table.end(), TTBucket());
|
||||||
table.clear();
|
|
||||||
table.resize(size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrefetchEntry(U64 &hashKey) {
|
void PrefetchEntry(U64 &hashKey) {
|
||||||
|
|||||||
+89
-15
@@ -4,6 +4,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <algorithm>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "movegen.h"
|
#include "movegen.h"
|
||||||
#include "search.h"
|
#include "search.h"
|
||||||
@@ -20,9 +21,55 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
constexpr size_t DefaultPositionHistorySize = 1000;
|
||||||
|
|
||||||
|
static void EnsurePositionHistory(SEARCH::SearchContext* ctx, int positionIndex) {
|
||||||
|
if (positionIndex >= static_cast<int>(ctx->positionHistory.size())) {
|
||||||
|
ctx->positionHistory.resize(positionIndex + 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ResetPositionHistory(SEARCH::SearchContext* ctx, const Board& board) {
|
||||||
|
const size_t historySize = std::max(DefaultPositionHistorySize, static_cast<size_t>(board.positionIndex + 100));
|
||||||
|
ctx->positionHistory.assign(historySize, 0);
|
||||||
|
ctx->positionHistory[board.positionIndex] = board.hashKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
static std::vector<std::thread> searchThreads;
|
||||||
|
#else
|
||||||
|
static std::vector<pthread_t> searchThreads;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static void JoinSearchThreads() {
|
||||||
|
#ifdef _WIN32
|
||||||
|
for (auto& thread : searchThreads) {
|
||||||
|
if (thread.joinable()) {
|
||||||
|
thread.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
for (pthread_t& thread : searchThreads) {
|
||||||
|
pthread_join(thread, nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
searchThreads.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void StopSearchThreads() {
|
||||||
|
searchStopped.store(true, std::memory_order_relaxed);
|
||||||
|
JoinSearchThreads();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
static void ParsePosition(Board &board, std::string_view command, SEARCH::SearchContext* ctx) {
|
static void ParsePosition(Board &board, std::string_view command, SEARCH::SearchContext* ctx) {
|
||||||
if (command.find("startpos") != std::string::npos) {
|
if (command.find("startpos") != std::string::npos) {
|
||||||
board.SetByFen(StartingFen);
|
board.SetByFen(StartingFen);
|
||||||
|
ResetPositionHistory(ctx, board);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fenIndex = command.find("fen");
|
int fenIndex = command.find("fen");
|
||||||
@@ -34,6 +81,8 @@ static void ParsePosition(Board &board, std::string_view command, SEARCH::Search
|
|||||||
} else {
|
} else {
|
||||||
board.SetByFen(command.substr(fenIndex + 4, command.length() - (fenIndex + 3)));
|
board.SetByFen(command.substr(fenIndex + 4, command.length() - (fenIndex + 3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResetPositionHistory(ctx, board);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (movesIndex != std::string::npos) {
|
if (movesIndex != std::string::npos) {
|
||||||
@@ -41,6 +90,7 @@ static void ParsePosition(Board &board, std::string_view command, SEARCH::Search
|
|||||||
|
|
||||||
for (std::string_view move : moves) {
|
for (std::string_view move : moves) {
|
||||||
board.MakeMove(UTILS::parseMove(board, move));
|
board.MakeMove(UTILS::parseMove(board, move));
|
||||||
|
EnsurePositionHistory(ctx, board.positionIndex);
|
||||||
ctx->positionHistory[board.positionIndex] = board.hashKey;
|
ctx->positionHistory[board.positionIndex] = board.hashKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,22 +139,21 @@ static double ReadParam(const std::string& param, const std::string &command) {
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Windows implementation using std::thread
|
// Windows implementation using std::thread
|
||||||
template <SEARCH::searchMode mode>
|
template <SEARCH::searchMode mode>
|
||||||
static void ThreadFunc(Board* board, SearchParams params, SEARCH::SearchContext* ctx) {
|
static void ThreadFunc(Board board, SearchParams params, SEARCH::SearchContext* ctx) {
|
||||||
SEARCH::SearchPosition<mode>(*board, params, ctx);
|
SEARCH::SearchPosition<mode>(board, params, ctx);
|
||||||
delete ctx;
|
delete ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StartSearchThread(Board& board, SearchParams params, SEARCH::SearchContext* ctx, int id) {
|
static void StartSearchThread(Board& board, SearchParams params, SEARCH::SearchContext* ctx, int id) {
|
||||||
std::thread searchThread;
|
|
||||||
SEARCH::SearchContext* ctxCopy = new SEARCH::SearchContext(*ctx);
|
SEARCH::SearchContext* ctxCopy = new SEARCH::SearchContext(*ctx);
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
ctxCopy->doPrint = true;
|
ctxCopy->doPrint = true;
|
||||||
|
|
||||||
if (params.nodes) {
|
if (params.nodes) {
|
||||||
searchThread = std::thread(ThreadFunc<SEARCH::nodesMode>, &board, params, ctxCopy);
|
searchThreads.emplace_back(ThreadFunc<SEARCH::nodesMode>, board, params, ctxCopy);
|
||||||
} else {
|
} else {
|
||||||
searchThread = std::thread(ThreadFunc<SEARCH::normal>, &board, params, ctxCopy);
|
searchThreads.emplace_back(ThreadFunc<SEARCH::normal>, board, params, ctxCopy);
|
||||||
}
|
}
|
||||||
searchThread.detach();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@@ -124,25 +173,46 @@ static void StartSearchThread(Board& board, SearchParams params, SEARCH::SearchC
|
|||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
pthread_attr_setstacksize(&attr, 8 * 1024 * 1024); // 8 MB stack
|
pthread_attr_setstacksize(&attr, 8 * 1024 * 1024); // 8 MB stack
|
||||||
|
|
||||||
pthread_t thread;
|
|
||||||
|
|
||||||
SEARCH::SearchContext* ctxCopy = new SEARCH::SearchContext(*ctx);
|
SEARCH::SearchContext* ctxCopy = new SEARCH::SearchContext(*ctx);
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
ctxCopy->doPrint = true;
|
ctxCopy->doPrint = true;
|
||||||
|
|
||||||
|
pthread_t thread;
|
||||||
|
int rc = 0;
|
||||||
|
|
||||||
if (params.nodes) {
|
if (params.nodes) {
|
||||||
auto* arg = new std::tuple<Board, SearchParams, SEARCH::SearchContext*>(board, params, ctxCopy);
|
auto* arg = new std::tuple<Board, SearchParams, SEARCH::SearchContext*>(board, params, ctxCopy);
|
||||||
pthread_create(&thread, &attr, ThreadFunc<SEARCH::nodesMode>, arg);
|
rc = pthread_create(&thread, &attr, ThreadFunc<SEARCH::nodesMode>, arg);
|
||||||
|
if (rc != 0) {
|
||||||
|
delete std::get<2>(*arg);
|
||||||
|
delete arg;
|
||||||
|
ctxCopy = nullptr;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auto* arg = new std::tuple<Board, SearchParams, SEARCH::SearchContext*>(board, params, ctxCopy);
|
auto* arg = new std::tuple<Board, SearchParams, SEARCH::SearchContext*>(board, params, ctxCopy);
|
||||||
pthread_create(&thread, &attr, ThreadFunc<SEARCH::normal>, arg);
|
rc = pthread_create(&thread, &attr, ThreadFunc<SEARCH::normal>, arg);
|
||||||
|
if (rc != 0) {
|
||||||
|
delete std::get<2>(*arg);
|
||||||
|
delete arg;
|
||||||
|
ctxCopy = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_attr_destroy(&attr);
|
pthread_attr_destroy(&attr);
|
||||||
pthread_detach(thread);
|
|
||||||
|
if (rc == 0) {
|
||||||
|
searchThreads.push_back(thread);
|
||||||
|
} else {
|
||||||
|
delete ctxCopy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void ParseGo(Board &board, std::string &command, SEARCH::SearchContext* ctx) {
|
static void ParseGo(Board &board, std::string &command, SEARCH::SearchContext* ctx) {
|
||||||
|
StopSearchThreads();
|
||||||
|
searchStopped.store(false, std::memory_order_relaxed);
|
||||||
|
ctx->TT->IncreaseAge();
|
||||||
|
|
||||||
SearchParams params;
|
SearchParams params;
|
||||||
|
|
||||||
params.wtime = ReadParam("wtime", command);
|
params.wtime = ReadParam("wtime", command);
|
||||||
@@ -160,12 +230,15 @@ static void ParseGo(Board &board, std::string &command, SEARCH::SearchContext* c
|
|||||||
params.btime = 99999999;
|
params.btime = 99999999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchThreads.reserve(threads);
|
||||||
for (int i = 0; i < threads; i++) {
|
for (int i = 0; i < threads; i++) {
|
||||||
StartSearchThread(board, params, ctx, i);
|
StartSearchThread(board, params, ctx, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SetOption(std::string& command, SEARCH::SearchContext* ctx) {
|
static void SetOption(std::string& command, SEARCH::SearchContext* ctx) {
|
||||||
|
StopSearchThreads();
|
||||||
|
|
||||||
if (command.find("Hash") != std::string::npos) {
|
if (command.find("Hash") != std::string::npos) {
|
||||||
U64 hashSize = (ReadParam("value", command) * 1000000ULL) / sizeof(TTEntry);
|
U64 hashSize = (ReadParam("value", command) * 1000000ULL) / sizeof(TTEntry);
|
||||||
ctx->TT->Resize(hashSize);
|
ctx->TT->Resize(hashSize);
|
||||||
@@ -228,7 +301,7 @@ static void SetOption(std::string& command, SEARCH::SearchContext* ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void PrintEngineInfo() {
|
static void PrintEngineInfo() {
|
||||||
std::cout << "id name Eleanor v4.0" << std::endl;
|
std::cout << "id name Eleanor v4.1" << std::endl;
|
||||||
std::cout << "id author rektdie" << std::endl;
|
std::cout << "id author rektdie" << std::endl;
|
||||||
std::cout << "option name Hash type spin default 8 min 1 max 1024" << std::endl;
|
std::cout << "option name Hash type spin default 8 min 1 max 1024" << std::endl;
|
||||||
std::cout << "option name Threads type spin default 1 min 1 max 512" << std::endl;
|
std::cout << "option name Threads type spin default 1 min 1 max 512" << std::endl;
|
||||||
@@ -265,6 +338,7 @@ void UCILoop(Board &board) {
|
|||||||
|
|
||||||
// parse UCI "ucinewgame" command
|
// parse UCI "ucinewgame" command
|
||||||
if (input.find("ucinewgame") != std::string::npos) {
|
if (input.find("ucinewgame") != std::string::npos) {
|
||||||
|
StopSearchThreads();
|
||||||
board.SetByFen(StartingFen);
|
board.SetByFen(StartingFen);
|
||||||
|
|
||||||
// Clearing
|
// Clearing
|
||||||
@@ -274,7 +348,7 @@ void UCILoop(Board &board) {
|
|||||||
ctx->history.Clear();
|
ctx->history.Clear();
|
||||||
ctx->conthist.Clear();
|
ctx->conthist.Clear();
|
||||||
ctx->corrhist.Clear();
|
ctx->corrhist.Clear();
|
||||||
ctx->positionHistory = {};
|
ResetPositionHistory(ctx.get(), board);
|
||||||
ctx->ss = {};
|
ctx->ss = {};
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@@ -288,14 +362,14 @@ void UCILoop(Board &board) {
|
|||||||
|
|
||||||
// parse UCI "quit" command
|
// parse UCI "quit" command
|
||||||
if (input.find("quit") != std::string::npos) {
|
if (input.find("quit") != std::string::npos) {
|
||||||
|
StopSearchThreads();
|
||||||
// stop the loop
|
// stop the loop
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse UCI "stop" command
|
// parse UCI "stop" command
|
||||||
if (input.find("stop") != std::string::npos) {
|
if (input.find("stop") != std::string::npos) {
|
||||||
// stop the loop
|
StopSearchThreads();
|
||||||
searchStopped = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,11 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
#include <atomic>
|
||||||
#include "move.h"
|
#include "move.h"
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
|
|
||||||
inline bool UCIEnabled = false;
|
inline bool UCIEnabled = false;
|
||||||
inline bool UCIShowWDL = false;
|
inline bool UCIShowWDL = false;
|
||||||
inline int threads = 1;
|
inline int threads = 1;
|
||||||
inline bool searchStopped = false;
|
inline std::atomic<bool> searchStopped = false;
|
||||||
|
|
||||||
class SearchParams {
|
class SearchParams {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in new issue
Block a user