namespace Search {
- volatile SignalsType Signals;
+ SignalsType Signals;
LimitsType Limits;
StateStackPtr SetupStates;
}
{
// Set up the new depth for the helper threads
if (!isMainThread)
- rootDepth = Threads.main()->rootDepth + Depth(int(3 * log(1 + this->idx)));
+ rootDepth = Threads.main()->rootDepth + Depth(int(2.2 * log(1 + this->idx)));
// Age out PV variability metric
if (isMainThread)
namespace {
- // search<>() is the main search function for both PV and non-PV nodes and for
- // normal and SplitPoint nodes. When called just after a split point the search
- // is simpler because we have already probed the hash table, done a null move
- // search, and searched the first move before splitting, so we don't have to
- // repeat all this work again. We also don't need to store anything to the hash
- // table here: This is taken care of after we return from the split point.
+ // search<>() is the main search function for both PV and non-PV nodes
template <NodeType NT>
Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode) {
if (!RootNode)
{
// Step 2. Check for aborted search and immediate draw
- if (Signals.stop || pos.is_draw() || ss->ply >= MAX_PLY)
- return ss->ply >= MAX_PLY && !inCheck ? evaluate(pos)
+ if (Signals.stop.load(std::memory_order_relaxed) || pos.is_draw() || ss->ply >= MAX_PLY)
+ return ss->ply >= MAX_PLY && !inCheck ? evaluate(pos)
: DrawValue[pos.side_to_move()];
// Step 3. Mate distance pruning. Even if we mate at the next move our score
if (RootNode && thisThread == Threads.main())
{
- Signals.firstRootMove = (moveCount == 1);
+ Signals.firstRootMove = moveCount == 1;
if (Time.elapsed() > 3000)
sync_cout << "info depth " << depth / ONE_PLY
// Finished searching the move. If a stop occurred, the return value of
// the search cannot be trusted, and we return immediately without
// updating best move, PV and TT.
- if (Signals.stop)
+ if (Signals.stop.load(std::memory_order_relaxed))
return VALUE_ZERO;
if (RootNode)
&& is_ok((ss - 1)->currentMove)
&& is_ok((ss - 2)->currentMove))
{
- Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + depth / ONE_PLY -1);
Square prevPrevSq = to_sq((ss - 2)->currentMove);
CounterMovesStats& prevCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
prevCmh.update(pos.piece_on(prevSq), prevSq, bonus);
ss->killers[0] = move;
}
- Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY));
+ Value bonus = Value((depth / ONE_PLY) * (depth / ONE_PLY) + depth / ONE_PLY -1);
Square prevSq = to_sq((ss-1)->currentMove);
CounterMovesStats& cmh = CounterMovesHistory[pos.piece_on(prevSq)][prevSq];
{
Square prevPrevSq = to_sq((ss-2)->currentMove);
CounterMovesStats& prevCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq];
- prevCmh.update(pos.piece_on(prevSq), prevSq, -bonus - 2 * depth / ONE_PLY - 1);
+ prevCmh.update(pos.piece_on(prevSq), prevSq, -bonus - 2 * ((depth + 1) / ONE_PLY));
}
}
{
bool stillAtFirstMove = Signals.firstRootMove
&& !Signals.failedLowAtRoot
- && elapsed > Time.available() * 75 / 100;
+ && elapsed > Time.available() * 3 / 4;
if ( stillAtFirstMove
|| elapsed > Time.maximum() - 2 * TimerThread::Resolution)