mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 00:33:09 +00:00
Make effort part of RootMove struct
Also includes several small cleanups. Passed STC: https://tests.stockfishchess.org/tests/view/65f15cfe0ec64f0526c473a0 LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 71136 W: 18456 L: 18273 D: 34407 Ptnml(0-2): 311, 8014, 18708, 8251, 284 closes https://github.com/official-stockfish/Stockfish/pull/5114 No functional change
This commit is contained in:
parent
23493de082
commit
abd82396a1
3 changed files with 5 additions and 13 deletions
|
@ -214,7 +214,7 @@ void Search::Worker::start_searching() {
|
||||||
// consumed, the user stops the search, or the maximum search depth is reached.
|
// consumed, the user stops the search, or the maximum search depth is reached.
|
||||||
void Search::Worker::iterative_deepening() {
|
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];
|
Move pv[MAX_PLY + 1];
|
||||||
|
|
||||||
|
@ -426,9 +426,7 @@ void Search::Worker::iterative_deepening() {
|
||||||
// Do we have time for the next iteration? Can we stop searching now?
|
// Do we have time for the next iteration? Can we stop searching now?
|
||||||
if (limits.use_time_management() && !threads.stop && !mainThread->stopOnPonderhit)
|
if (limits.use_time_management() && !threads.stop && !mainThread->stopOnPonderhit)
|
||||||
{
|
{
|
||||||
auto bestmove = rootMoves[0].pv[0];
|
int nodesEffort = rootMoves[0].effort * 100 / std::max(size_t(1), size_t(nodes));
|
||||||
int nodesEffort = effort[bestmove.from_sq()][bestmove.to_sq()] * 100
|
|
||||||
/ std::max(size_t(1), size_t(nodes));
|
|
||||||
|
|
||||||
double fallingEval = (1067 + 223 * (mainThread->bestPreviousAverageScore - bestValue)
|
double fallingEval = (1067 + 223 * (mainThread->bestPreviousAverageScore - bestValue)
|
||||||
+ 97 * (mainThread->iterValue[iterIdx] - bestValue))
|
+ 97 * (mainThread->iterValue[iterIdx] - bestValue))
|
||||||
|
@ -450,9 +448,7 @@ void Search::Worker::iterative_deepening() {
|
||||||
if (completedDepth >= 10 && nodesEffort >= 97
|
if (completedDepth >= 10 && nodesEffort >= 97
|
||||||
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.739
|
&& mainThread->tm.elapsed(threads.nodes_searched()) > totalTime * 0.739
|
||||||
&& !mainThread->ponder)
|
&& !mainThread->ponder)
|
||||||
{
|
|
||||||
threads.stop = true;
|
threads.stop = true;
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the search if we have exceeded the totalTime
|
// Stop the search if we have exceeded the totalTime
|
||||||
if (mainThread->tm.elapsed(threads.nodes_searched()) > totalTime)
|
if (mainThread->tm.elapsed(threads.nodes_searched()) > totalTime)
|
||||||
|
@ -1199,9 +1195,6 @@ moves_loop: // When in check, search starts here
|
||||||
// Step 19. Undo move
|
// Step 19. Undo move
|
||||||
pos.undo_move(move);
|
pos.undo_move(move);
|
||||||
|
|
||||||
if (rootNode)
|
|
||||||
effort[move.from_sq()][move.to_sq()] += nodes - nodeCount;
|
|
||||||
|
|
||||||
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
assert(value > -VALUE_INFINITE && value < VALUE_INFINITE);
|
||||||
|
|
||||||
// Step 20. Check for a new best move
|
// Step 20. Check for a new best move
|
||||||
|
@ -1216,6 +1209,8 @@ moves_loop: // When in check, search starts here
|
||||||
RootMove& rm =
|
RootMove& rm =
|
||||||
*std::find(thisThread->rootMoves.begin(), thisThread->rootMoves.end(), move);
|
*std::find(thisThread->rootMoves.begin(), thisThread->rootMoves.end(), move);
|
||||||
|
|
||||||
|
rm.effort += nodes - nodeCount;
|
||||||
|
|
||||||
rm.averageScore =
|
rm.averageScore =
|
||||||
rm.averageScore != -VALUE_INFINITE ? (2 * value + rm.averageScore) / 3 : value;
|
rm.averageScore != -VALUE_INFINITE ? (2 * value + rm.averageScore) / 3 : value;
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,7 @@ struct RootMove {
|
||||||
return m.score != score ? m.score < score : m.previousScore < previousScore;
|
return m.score != score ? m.score < score : m.previousScore < previousScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t effort = 0;
|
||||||
Value score = -VALUE_INFINITE;
|
Value score = -VALUE_INFINITE;
|
||||||
Value previousScore = -VALUE_INFINITE;
|
Value previousScore = -VALUE_INFINITE;
|
||||||
Value averageScore = -VALUE_INFINITE;
|
Value averageScore = -VALUE_INFINITE;
|
||||||
|
@ -230,8 +231,6 @@ class Worker {
|
||||||
return static_cast<SearchManager*>(manager.get());
|
return static_cast<SearchManager*>(manager.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<std::array<uint64_t, SQUARE_NB>, SQUARE_NB> effort;
|
|
||||||
|
|
||||||
LimitsType limits;
|
LimitsType limits;
|
||||||
|
|
||||||
size_t pvIdx, pvLast;
|
size_t pvIdx, pvLast;
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -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->rootPos.set(pos.fen(), pos.is_chess960(), &th->worker->rootState);
|
||||||
th->worker->rootState = setupStates->back();
|
th->worker->rootState = setupStates->back();
|
||||||
th->worker->tbConfig = tbConfig;
|
th->worker->tbConfig = tbConfig;
|
||||||
th->worker->effort = {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main_thread()->start_searching();
|
main_thread()->start_searching();
|
||||||
|
|
Loading…
Add table
Reference in a new issue