Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make effort part of RootMove struct. #5114

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ void Search::Worker::start_searching() {
// consumed, the user stops the search, or the maximum search depth is reached.
void Search::Worker::iterative_deepening() {

SearchManager* mainThread = (thread_idx == 0 ? main_manager() : nullptr);
SearchManager* mainThread = (is_mainthread() ? main_manager() : nullptr);

Move pv[MAX_PLY + 1];

Expand Down Expand Up @@ -426,9 +426,7 @@ void Search::Worker::iterative_deepening() {
// Do we have time for the next iteration? Can we stop searching now?
if (limits.use_time_management() && !threads.stop && !mainThread->stopOnPonderhit)
{
auto bestmove = rootMoves[0].pv[0];
int nodesEffort = effort[bestmove.from_sq()][bestmove.to_sq()] * 100
/ std::max(size_t(1), size_t(nodes));
int nodesEffort = rootMoves[0].effort * 100 / std::max(size_t(1), size_t(nodes));

double fallingEval = (1067 + 223 * (mainThread->bestPreviousAverageScore - bestValue)
+ 97 * (mainThread->iterValue[iterIdx] - bestValue))
Expand All @@ -450,9 +448,7 @@ void Search::Worker::iterative_deepening() {
if (completedDepth >= 10 && nodesEffort >= 97
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.739
&& !mainThread->ponder)
{
threads.stop = true;
}

// Stop the search if we have exceeded the totalTime
if (mainThread->tm.elapsed(threads.nodes_searched()) > totalTime)
Expand Down Expand Up @@ -1199,9 +1195,6 @@ Value Search::Worker::search(
// Step 19. Undo move
pos.undo_move(move);

if (rootNode)
effort[move.from_sq()][move.to_sq()] += nodes - nodeCount;

assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);

// Step 20. Check for a new best move
Expand All @@ -1216,6 +1209,8 @@ Value Search::Worker::search(
RootMove& rm =
*std::find(thisThread->rootMoves.begin(), thisThread->rootMoves.end(), move);

rm.effort += nodes - nodeCount;

rm.averageScore =
rm.averageScore != -VALUE_INFINITE ? (2 * value + rm.averageScore) / 3 : value;

Expand Down
3 changes: 1 addition & 2 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ struct RootMove {
return m.score != score ? m.score < score : m.previousScore < previousScore;
}

uint64_t effort = 0;
Value score = -VALUE_INFINITE;
Value previousScore = -VALUE_INFINITE;
Value averageScore = -VALUE_INFINITE;
Expand Down Expand Up @@ -230,8 +231,6 @@ class Worker {
return static_cast<SearchManager*>(manager.get());
}

std::array<std::array<uint64_t, SQUARE_NB>, SQUARE_NB> effort;

LimitsType limits;

size_t pvIdx, pvLast;
Expand Down
2 changes: 0 additions & 2 deletions src/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "thread.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <deque>
#include <memory>
Expand Down Expand Up @@ -211,7 +210,6 @@ void ThreadPool::start_thinking(const OptionsMap& options,
th->worker->rootPos.set(pos.fen(), pos.is_chess960(), &th->worker->rootState);
th->worker->rootState = setupStates->back();
th->worker->tbConfig = tbConfig;
th->worker->effort = {};
}

main_thread()->start_searching();
Expand Down
Loading