bool is_chess960() const;
Thread* this_thread() const;
uint64_t nodes_searched() const;
- void set_nodes_searched(uint64_t n);
bool is_draw() const;
int rule50_count() const;
Score psq_score() const;
return nodes;
}
-inline void Position::set_nodes_searched(uint64_t n) {
- nodes = n;
-}
-
inline bool Position::opposite_bishops() const {
return pieceCount[W_BISHOP] == 1
&& pieceCount[B_BISHOP] == 1
namespace Tablebases {
int Cardinality;
- uint64_t Hits;
bool RootInTB;
bool UseRule50;
Depth ProbeDepth;
if (found)
{
- TB::Hits++;
+ thisThread->tbHits++;
int drawScore = TB::UseRule50 ? 1 : 0;
if ( (Limits.use_time_management() && elapsed > Time.maximum() - 10)
|| (Limits.movetime && elapsed >= Limits.movetime)
- || (Limits.nodes && Threads.nodes_searched() >= Limits.nodes))
+ || (Limits.nodes && Threads.nodes_searched() >= (uint64_t)Limits.nodes))
Signals.stop = true;
}
const RootMoves& rootMoves = pos.this_thread()->rootMoves;
size_t PVIdx = pos.this_thread()->PVIdx;
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size());
- uint64_t nodes_searched = Threads.nodes_searched();
+ uint64_t nodesSearched = Threads.nodes_searched();
+ uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);
for (size_t i = 0; i < multiPV; ++i)
{
if (!tb && i == PVIdx)
ss << (v >= beta ? " lowerbound" : v <= alpha ? " upperbound" : "");
- ss << " nodes " << nodes_searched
- << " nps " << nodes_searched * 1000 / elapsed;
+ ss << " nodes " << nodesSearched
+ << " nps " << nodesSearched * 1000 / elapsed;
if (elapsed > 1000) // Earlier makes little sense
ss << " hashfull " << TT.hashfull();
- ss << " tbhits " << TB::Hits
+ ss << " tbhits " << tbHits
<< " time " << elapsed
<< " pv";
void Tablebases::filter_root_moves(Position& pos, Search::RootMoves& rootMoves) {
- Hits = 0;
RootInTB = false;
UseRule50 = Options["Syzygy50MoveRule"];
ProbeDepth = Options["SyzygyProbeDepth"] * ONE_PLY;
Cardinality = 0;
}
- if (RootInTB)
- {
- Hits = rootMoves.size();
-
- if (!UseRule50)
- TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
- : TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
- : VALUE_DRAW;
- }
+ if (RootInTB && !UseRule50)
+ TB::Score = TB::Score > VALUE_DRAW ? VALUE_MATE - MAX_PLY - 1
+ : TB::Score < VALUE_DRAW ? -VALUE_MATE + MAX_PLY + 1
+ : VALUE_DRAW;
}
Thread::Thread() {
resetCalls = exit = false;
- maxPly = callsCnt = 0;
+ maxPly = callsCnt = tbHits = 0;
history.clear();
counterMoves.clear();
idx = Threads.size(); // Start from 0
/// ThreadPool::nodes_searched() returns the number of nodes searched
-int64_t ThreadPool::nodes_searched() {
+uint64_t ThreadPool::nodes_searched() {
- int64_t nodes = 0;
+ uint64_t nodes = 0;
for (Thread* th : *this)
nodes += th->rootPos.nodes_searched();
return nodes;
}
+/// ThreadPool::tb_hits() returns the number of TB hits
+
+uint64_t ThreadPool::tb_hits() {
+
+ uint64_t hits = 0;
+ for (Thread* th : *this)
+ hits += th->tbHits;
+ return hits;
+}
+
+
/// ThreadPool::start_thinking() wakes up the main thread sleeping in idle_loop()
/// and starts a new search, then returns immediately.
Endgames endgames;
size_t idx, PVIdx;
int maxPly, callsCnt;
+ uint64_t tbHits;
Position rootPos;
Search::RootMoves rootMoves;
MainThread* main() { return static_cast<MainThread*>(at(0)); }
void start_thinking(Position&, StateListPtr&, const Search::LimitsType&);
void read_uci_options();
- int64_t nodes_searched();
+ uint64_t nodes_searched();
+ uint64_t tb_hits();
private:
StateListPtr setupStates;