// Do we have to play with skill handicap? In this case enable MultiPV that
// we will use behind the scenes to retrieve a set of possible moves.
SkillLevelEnabled = (SkillLevel < 20);
- MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, 4U) : UCIMultiPV);
+ MultiPV = (SkillLevelEnabled ? std::max(UCIMultiPV, (size_t)4) : UCIMultiPV);
// Write current search header to log file
if (Options["Use Search Log"].value<bool>())
{
lock_grab(&(sp->lock));
bestValue = sp->bestValue;
+ moveCount = sp->moveCount;
+
+ assert(bestValue > -VALUE_INFINITE && moveCount > 0);
}
// Step 11. Loop through moves
&& !inCheck
&& !dangerous
&& move != ttMove
- && !is_castle(move))
+ && !is_castle(move)
+ && (bestValue > VALUE_MATED_IN_PLY_MAX || bestValue == -VALUE_INFINITE))
{
// Move count based pruning
if ( moveCount >= futility_move_count(depth)
- && (!threatMove || !connected_threat(pos, move, threatMove))
- && bestValue > VALUE_MATED_IN_PLY_MAX) // FIXME bestValue is racy
+ && (!threatMove || !connected_threat(pos, move, threatMove)))
{
if (SpNode)
lock_grab(&(sp->lock));
if (futilityValue < beta)
{
if (SpNode)
- {
lock_grab(&(sp->lock));
- if (futilityValue > sp->bestValue)
- sp->bestValue = bestValue = futilityValue;
- }
- else if (futilityValue > bestValue)
- bestValue = futilityValue;
continue;
}
// Prune moves with negative SEE at low depths
if ( predictedDepth < 2 * ONE_PLY
- && bestValue > VALUE_MATED_IN_PLY_MAX
&& pos.see_sign(move) < 0)
{
if (SpNode)
// case of StopRequest or thread.cutoff_occurred() are set, but this is
// harmless because return value is discarded anyhow in the parent nodes.
// If we are in a singular extension search then return a fail low score.
- if (!SpNode && !moveCount)
+ if (!moveCount)
return excludedMove ? oldAlpha : inCheck ? value_mated_in(ss->ply) : VALUE_DRAW;
+ // We have pruned all the moves, so return a fail-low score
+ if (bestValue == -VALUE_INFINITE)
+ {
+ assert(!playedMoveCount);
+
+ bestValue = alpha;
+ }
+
// Step 21. Update tables
// If the search is not aborted, update the transposition table,
// history counters, and killer moves.