// History and stats update bonus, based on depth
int stat_bonus(Depth depth) {
- int d = depth / ONE_PLY ;
+ int d = depth / ONE_PLY;
return d > 17 ? 0 : d * d + 2 * d - 2;
}
MainThread* mainThread = (this == Threads.main() ? Threads.main() : nullptr);
std::memset(ss-4, 0, 7 * sizeof(Stack));
- for(int i = 4; i > 0; i--)
+ for (int i = 4; i > 0; i--)
(ss-i)->history = &this->counterMoveHistory[NO_PIECE][0]; // Use as sentinel
bestValue = delta = alpha = -VALUE_INFINITE;
multiPV = std::min(multiPV, rootMoves.size());
// Iterative deepening loop until requested to stop or the target depth is reached
- while ( (rootDepth += ONE_PLY) < DEPTH_MAX
+ while ( (rootDepth = rootDepth + ONE_PLY) < DEPTH_MAX
&& !Signals.stop
&& (!Limits.depth || Threads.main()->rootDepth / ONE_PLY <= Limits.depth))
{
{
bestValue = ::search<PV>(rootPos, ss, alpha, beta, rootDepth, false, false);
+ this->tbHits = rootPos.tb_hits();
+ this->nodes = rootPos.nodes_searched();
+
// Bring the best move to the front. It is critical that sorting
// is done with a stable algorithm because all the values but the
// first and eventually the new best one are set to -VALUE_INFINITE
{
thisThread->resetCalls = false;
+ thisThread->tbHits = pos.tb_hits();
+ thisThread->nodes = pos.nodes_searched();
+
// At low node count increase the checking rate to about 0.1% of nodes
// otherwise use a default value.
thisThread->callsCnt = Limits.nodes ? std::min(4096, int(Limits.nodes / 1024))
if (err != TB::ProbeState::FAIL)
{
- thisThread->tbHits++;
+ pos.increment_tbHits();
int drawScore = TB::UseRule50 ? 1 : 0;
void check_time() {
- static TimePoint lastInfoTime = now();
+ static std::atomic<TimePoint> lastInfoTime = { now() };
int elapsed = Time.elapsed();
TimePoint tick = Limits.startTime + elapsed;