void id_loop(Position& pos);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
- bool check_is_dangerous(Position& pos, Move move, Value futilityBase, Value beta);
+ bool check_is_dangerous(const Position& pos, Move move, Value futilityBase, Value beta);
bool allows(const Position& pos, Move first, Move second);
bool refutes(const Position& pos, Move first, Move second);
string uci_pv(const Position& pos, int depth, Value alpha, Value beta);
// Reset the threads, still sleeping: will be wake up at split time
for (size_t i = 0; i < Threads.size(); i++)
- Threads[i].maxPly = 0;
+ Threads[i]->maxPly = 0;
Threads.sleepWhileIdle = Options["Use Sleeping Threads"];
// Set best timer interval to avoid lagging under time pressure. Timer is
// used to check for remaining available thinking time.
- Threads.timer_thread()->msec =
+ Threads.timer->msec =
Limits.use_time_management() ? std::min(100, std::max(TimeMgr.available_time() / 16, TimerResolution)) :
Limits.nodes ? 2 * TimerResolution
: 100;
- Threads.timer_thread()->notify_one(); // Wake up the recurring timer
+ Threads.timer->notify_one(); // Wake up the recurring timer
id_loop(RootPos); // Let's start searching !
- Threads.timer_thread()->msec = 0; // Stop the timer
+ Threads.timer->msec = 0; // Stop the timer
Threads.sleepWhileIdle = true; // Send idle threads to sleep
if (Options["Use Search Log"])
else if (tte)
{
// Never assume anything on values stored in TT
- if ( (ss->staticEval = eval = tte->static_value()) == VALUE_NONE
- ||(ss->evalMargin = tte->static_value_margin()) == VALUE_NONE)
+ if ( (ss->staticEval = eval = tte->eval_value()) == VALUE_NONE
+ ||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
eval = ss->staticEval = evaluate(pos, ss->evalMargin);
// Can ttValue be used as a better position evaluation?
// Step 19. Check for splitting the search
if ( !SpNode
&& depth >= Threads.minimumSplitDepth
- && Threads.slave_available(thisThread)
+ && Threads.available_slave(thisThread)
&& thisThread->splitPointsSize < MAX_SPLITPOINTS_PER_THREAD)
{
assert(bestValue < beta);
- bestValue = thisThread->split<FakeSplit>(pos, ss, alpha, beta, bestValue, &bestMove,
- depth, threatMove, moveCount, mp, NT);
+ thisThread->split<FakeSplit>(pos, ss, alpha, beta, &bestValue, &bestMove,
+ depth, threatMove, moveCount, &mp, NT);
if (bestValue >= beta)
break;
}
if (tte)
{
// Never assume anything on values stored in TT
- if ( (ss->staticEval = bestValue = tte->static_value()) == VALUE_NONE
- ||(ss->evalMargin = tte->static_value_margin()) == VALUE_NONE)
+ if ( (ss->staticEval = bestValue = tte->eval_value()) == VALUE_NONE
+ ||(ss->evalMargin = tte->eval_margin()) == VALUE_NONE)
ss->staticEval = bestValue = evaluate(pos, ss->evalMargin);
}
else
// check_is_dangerous() tests if a checking move can be pruned in qsearch()
- bool check_is_dangerous(Position& pos, Move move, Value futilityBase, Value beta)
+ bool check_is_dangerous(const Position& pos, Move move, Value futilityBase, Value beta)
{
Piece pc = pos.piece_moved(move);
Square from = from_sq(move);
int selDepth = 0;
for (size_t i = 0; i < Threads.size(); i++)
- if (Threads[i].maxPly > selDepth)
- selDepth = Threads[i].maxPly;
+ if (Threads[i]->maxPly > selDepth)
+ selDepth = Threads[i]->maxPly;
for (size_t i = 0; i < uciPVSize; i++)
{
sp->mutex.lock();
- assert(sp->slavesPositions[idx] == NULL);
+ assert(activePosition == NULL);
- sp->slavesPositions[idx] = &pos;
+ activePosition = &pos;
switch (sp->nodeType) {
case Root:
assert(searching);
searching = false;
- sp->slavesPositions[idx] = NULL;
+ activePosition = NULL;
sp->slavesMask &= ~(1ULL << idx);
sp->nodes += pos.nodes_searched();
nodes = RootPos.nodes_searched();
// Loop across all split points and sum accumulated SplitPoint nodes plus
- // all the currently active slaves positions.
+ // all the currently active positions nodes.
for (size_t i = 0; i < Threads.size(); i++)
- for (int j = 0; j < Threads[i].splitPointsSize; j++)
+ for (int j = 0; j < Threads[i]->splitPointsSize; j++)
{
- SplitPoint& sp = Threads[i].splitPoints[j];
+ SplitPoint& sp = Threads[i]->splitPoints[j];
sp.mutex.lock();
Bitboard sm = sp.slavesMask;
while (sm)
{
- Position* pos = sp.slavesPositions[pop_lsb(&sm)];
- nodes += pos ? pos->nodes_searched() : 0;
+ Position* pos = Threads[pop_lsb(&sm)]->activePosition;
+ if (pos)
+ nodes += pos->nodes_searched();
}
sp.mutex.unlock();