const bool RootNode = (NT == Root || NT == SplitPointRoot);
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
- assert(PvNode == (alpha != beta - 1));
+ assert((alpha == beta - 1) || PvNode);
assert(depth > DEPTH_ZERO);
assert(pos.thread() >= 0 && pos.thread() < Threads.size());
Depth rdepth = depth - ONE_PLY - 3 * ONE_PLY;
assert(rdepth >= ONE_PLY);
+ assert((ss-1)->currentMove != MOVE_NONE);
MovePicker mp(pos, ttMove, H, pos.captured_piece_type());
CheckInfo ci(pos);
while ((move = mp.next_move()) != MOVE_NONE)
if (pos.pl_move_is_legal(move, ci.pinned))
{
+ ss->currentMove = move;
pos.do_move(move, st, ci, pos.move_gives_check(move, ci));
value = -search<NonPV>(pos, ss+1, -rbeta, -rbeta+1, rdepth);
pos.undo_move(move);
&& tte->depth() >= depth - 3 * ONE_PLY;
if (SpNode)
{
- lock_grab(&(sp->lock));
+ lock_grab(sp->lock);
bestValue = sp->bestValue;
moveCount = sp->moveCount;
if (SpNode)
{
moveCount = ++sp->moveCount;
- lock_release(&(sp->lock));
+ lock_release(sp->lock);
}
else
moveCount++;
&& (!threatMove || !connected_threat(pos, move, threatMove)))
{
if (SpNode)
- lock_grab(&(sp->lock));
+ lock_grab(sp->lock);
continue;
}
if (futilityValue < beta)
{
if (SpNode)
- lock_grab(&(sp->lock));
+ lock_grab(sp->lock);
continue;
}
&& pos.see_sign(move) < 0)
{
if (SpNode)
- lock_grab(&(sp->lock));
+ lock_grab(sp->lock);
continue;
}
// Step 18. Check for new best move
if (SpNode)
{
- lock_grab(&(sp->lock));
+ lock_grab(sp->lock);
bestValue = sp->bestValue;
alpha = sp->alpha;
}
// Here we have the lock still grabbed
sp->is_slave[pos.thread()] = false;
sp->nodes += pos.nodes_searched();
- lock_release(&(sp->lock));
+ lock_release(sp->lock);
}
assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);
assert(NT == PV || NT == NonPV);
assert(alpha >= -VALUE_INFINITE && alpha < beta && beta <= VALUE_INFINITE);
- assert(PvNode == (alpha != beta - 1));
+ assert((alpha == beta - 1) || PvNode);
assert(depth <= DEPTH_ZERO);
assert(pos.thread() >= 0 && pos.thread() < Threads.size());
}
// Grab the lock to avoid races with Thread::wake_up()
- lock_grab(&sleepLock);
+ lock_grab(sleepLock);
// If we are master and all slaves have finished don't go to sleep
if (sp && Threads.split_point_finished(sp))
{
- lock_release(&sleepLock);
+ lock_release(sleepLock);
break;
}
// in the meanwhile, allocated us and sent the wake_up() call before we
// had the chance to grab the lock.
if (do_sleep || !is_searching)
- cond_wait(&sleepCond, &sleepLock);
+ cond_wait(sleepCond, sleepLock);
- lock_release(&sleepLock);
+ lock_release(sleepLock);
}
// If this thread has been assigned work, launch a search
{
// Because sp->is_slave[] is reset under lock protection,
// be sure sp->lock has been released before to return.
- lock_grab(&(sp->lock));
- lock_release(&(sp->lock));
+ lock_grab(sp->lock);
+ lock_release(sp->lock);
return;
}
}