- value = newDepth < ONE_PLY ?
- givesCheck ? -qsearch<NonPV, true>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
- : -qsearch<NonPV, false>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
- : - search<NonPV>(pos, ss+1, -(alpha+1), -alpha, newDepth);
+ value = newDepth < ONE_PLY ?
+ givesCheck ? -qsearch<NonPV, true>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
+ : -qsearch<NonPV, false>(pos, ss+1, -(alpha+1), -alpha, DEPTH_ZERO)
+ : - search<NonPV, false>(pos, ss+1, -(alpha+1), -alpha, newDepth, !cutNode);
+ }
+
+ // For PV nodes only, 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 fail low with value <= alpha and to try another move.
+ if (PvNode && (moveCount == 1 || (value > alpha && (RootNode || value < beta))))
+ {
+ (ss+1)->pv = pv;
+ (ss+1)->pv[0] = MOVE_NONE;
+
+ value = newDepth < ONE_PLY ?
+ givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
+ : -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
+ : - search<PV, false>(pos, ss+1, -beta, -alpha, newDepth, false);