major bugfix in ID(used to pass SearchParams as reference)
This commit is contained in:
1 parent
5bf50af74b
commit
cdbf9d4b28
5 files changed
+10
-9
No files matched your search
+1
-1
@@ -3,4 +3,4 @@ obj/
|
||||
|
||||
# Ignore executable files
|
||||
*.exe
|
||||
Engine-Eleanor
|
||||
Eleanor
|
||||
@@ -6,7 +6,7 @@ OBJ_DIR := obj
|
||||
CXX ?= g++
|
||||
|
||||
# Set default executable name, but allow override from the command line
|
||||
EXE ?= Engine-Eleanor
|
||||
EXE ?= Eleanor
|
||||
|
||||
# Determine platform
|
||||
ifeq ($(OS),Windows_NT)
|
||||
|
||||
+5
-4
@@ -121,6 +121,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
if (!benchStarted) {
|
||||
auto currTime = std::chrono::high_resolution_clock::now();
|
||||
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count();
|
||||
|
||||
if (elapsed >= timeToSearch) {
|
||||
StopSearch();
|
||||
return 0;
|
||||
@@ -187,15 +188,15 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
}
|
||||
|
||||
// Iterative deepening
|
||||
static SearchResults ID(Board &board, SearchParams ¶ms) {
|
||||
static SearchResults ID(Board &board, SearchParams params) {
|
||||
timeStart = std::chrono::high_resolution_clock::now();
|
||||
|
||||
int fullTime = board.sideToMove ? params.btime : params.wtime;
|
||||
int inc = board.sideToMove ? params.binc : params.winc;
|
||||
|
||||
SearchResults safeResults;
|
||||
for (int depth = 1; depth <= 8; depth++) {
|
||||
int timeRemaining = fullTime / 20 + inc / 2;
|
||||
for (int depth = 1; depth <= 99; depth++) {
|
||||
int timeRemaining = (fullTime / 20) + (inc / 2);
|
||||
timeToSearch = timeRemaining;
|
||||
|
||||
SearchResults currentResults = PVS(board, depth, -50000, 50000);
|
||||
@@ -209,7 +210,7 @@ static SearchResults ID(Board &board, SearchParams ¶ms) {
|
||||
return safeResults;
|
||||
}
|
||||
|
||||
void SearchPosition(Board &board, SearchParams ¶ms) {
|
||||
void SearchPosition(Board &board, SearchParams params) {
|
||||
searchStopped = false;
|
||||
nodes = 0;
|
||||
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public:
|
||||
};
|
||||
|
||||
SearchResults PVS(Board board, int depth, int alpha, int beta);
|
||||
void SearchPosition(Board &board, SearchParams ¶ms);
|
||||
void SearchPosition(Board &board, SearchParams params);
|
||||
void StopSearch();
|
||||
|
||||
constexpr int moveScoreTable[6][6] = {
|
||||
|
||||
+2
-2
@@ -146,7 +146,7 @@ static int ReadParam(std::string param, std::string &command) {
|
||||
std::string result = "";
|
||||
pos += param.length() + 1;
|
||||
|
||||
while(pos <= command.length() && std::isdigit(command[pos])){
|
||||
while(pos < command.length() && std::isdigit(command[pos])){
|
||||
result += command[pos];
|
||||
pos++;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ void ParseGo(Board &board, std::string &command) {
|
||||
params.binc = ReadParam("binc", command);
|
||||
params.movesToGo = ReadParam("movestogo", command);
|
||||
|
||||
auto worker = std::thread(SearchPosition, std::ref(board), std::ref(params));
|
||||
auto worker = std::thread(SearchPosition, std::ref(board), params);
|
||||
worker.detach();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user