added stop UCI command + little adjustments
This commit is contained in:
1 parent
aaa3a72081
commit
81c52f05e3
5 files changed
+39
-11
No files matched your search
+18
-5
@@ -62,10 +62,12 @@ void ListScores(Board &board) {
|
||||
}
|
||||
|
||||
static SearchResults Quiescence(Board board, int alpha, int beta) {
|
||||
if (searchStopped) return 0;
|
||||
|
||||
auto currTime = std::chrono::high_resolution_clock::now();
|
||||
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count();
|
||||
if (elapsed >= timeToSearch) {
|
||||
searchStopped = true;
|
||||
StopSearch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -109,10 +111,12 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
|
||||
}
|
||||
|
||||
static SearchResults PVS(Board board, int depth, int alpha, int beta) {
|
||||
if (searchStopped) return 0;
|
||||
|
||||
auto currTime = std::chrono::high_resolution_clock::now();
|
||||
int elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(currTime - timeStart).count();
|
||||
if (elapsed >= timeToSearch) {
|
||||
searchStopped = true;
|
||||
StopSearch();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -192,9 +196,6 @@ SearchResults ID(Board &board, SearchParams ¶ms) {
|
||||
safeResults = currentResults;
|
||||
}
|
||||
|
||||
std::cout << "info nodes " << nodes << '\n';
|
||||
std::cout << timeRemaining << std::endl;
|
||||
|
||||
if (searchStopped) break;
|
||||
}
|
||||
|
||||
@@ -203,8 +204,20 @@ SearchResults ID(Board &board, SearchParams ¶ms) {
|
||||
|
||||
void SearchPosition(Board &board, SearchParams ¶ms) {
|
||||
searchStopped = false;
|
||||
|
||||
|
||||
SearchResults results = ID(board, params);
|
||||
auto currTime = std::chrono::high_resolution_clock::now();
|
||||
double elapsed = std::chrono::duration_cast<
|
||||
std::chrono::duration<double>>(currTime - timeStart).count();
|
||||
|
||||
std::cout << "info " << nodes << " nodes " << nodes/elapsed << " nps\n";
|
||||
std::cout << "bestmove " << squareCoords[results.bestMove.MoveFrom()]
|
||||
<< squareCoords[results.bestMove.MoveTo()] << '\n';
|
||||
nodes = 0;
|
||||
}
|
||||
|
||||
void StopSearch() {
|
||||
searchStopped = true;
|
||||
std::cout << "Search stopped\n";
|
||||
}
|
||||
Reference in new issue
Block a user