Bound bt;
Value bestValue, value, oldAlpha, ttValue;
Value refinedValue, nullValue, futilityBase, futilityValue;
- bool isPvMove, inCheck, singularExtensionNode, givesCheck;
+ bool pvMove, inCheck, singularExtensionNode, givesCheck;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount = 0, playedMoveCount = 0;
Thread* thisThread = pos.this_thread();
if (RootNode && !std::count(RootMoves.begin() + PVIdx, RootMoves.end(), move))
continue;
- // At PV and SpNode nodes we want all moves to be legal since the beginning
- if ((PvNode || SpNode) && !pos.pl_move_is_legal(move, ci.pinned))
- continue;
-
if (SpNode)
{
+ // Shared counter cannot be decremented later if move turns out to be illegal
+ if (!pos.pl_move_is_legal(move, ci.pinned))
+ continue;
+
moveCount = ++sp->moveCount;
sp->mutex.unlock();
}
<< " currmovenumber " << moveCount + PVIdx << sync_endl;
}
- isPvMove = (PvNode && moveCount <= 1);
captureOrPromotion = pos.is_capture_or_promotion(move);
givesCheck = pos.move_gives_check(move, ci);
dangerous = givesCheck || is_dangerous(pos, move, captureOrPromotion);
continue;
}
+ pvMove = PvNode ? moveCount <= 1 : false;
ss->currentMove = move;
if (!SpNode && !captureOrPromotion && playedMoveCount < 64)
movesSearched[playedMoveCount++] = move;
// Step 15. Reduced depth search (LMR). If the move fails high will be
// re-searched at full depth.
if ( depth > 3 * ONE_PLY
- && !isPvMove
+ && !pvMove
&& !captureOrPromotion
&& !dangerous
&& ss->killers[0] != move
ss->reduction = DEPTH_ZERO;
}
else
- doFullDepthSearch = !isPvMove;
+ doFullDepthSearch = !pvMove;
// Step 16. Full depth search, when LMR is skipped or fails high
if (doFullDepthSearch)
// Only for PV nodes do a full PV search on the first move or after a fail
// high, in the latter case search only if value < beta, otherwise let the
// parent node to fail low with value <= alpha and to try another move.
- if (PvNode && (isPvMove || (value > alpha && (RootNode || value < beta))))
+ if (PvNode && (pvMove || (value > alpha && (RootNode || value < beta))))
value = newDepth < ONE_PLY ? -qsearch<PV>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: - search<PV>(pos, ss+1, -beta, -alpha, newDepth);
RootMove& rm = *std::find(RootMoves.begin(), RootMoves.end(), move);
// PV move or new best move ?
- if (isPvMove || value > alpha)
+ if (pvMove || value > alpha)
{
rm.score = value;
rm.extract_pv_from_tt(pos);
// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
// the best move changes frequently, we allocate some more time.
- if (!isPvMove && MultiPV == 1)
+ if (!pvMove && MultiPV == 1)
BestMoveChanges++;
}
else