- else value = alpha + 1;
- if(value > alpha) {
- ss[ply].reduction = Depth(0);
- value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID);
- if(value > alpha && value < beta) {
- if(ply == 1 && RootMoveNumber == 1)
- // When the search fails high at ply 1 while searching the first
- // move at the root, set the flag failHighPly1. This is used for
- // time managment: We don't want to stop the search early in
- // such cases, because resolving the fail high at ply 1 could
- // result in a big drop in score at the root.
- Threads[threadID].failHighPly1 = true;
- value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1,
- threadID);
- Threads[threadID].failHighPly1 = false;
+ else
+ value = alpha + 1; // Just to trigger next condition
+
+ if (value > alpha) // Go with full depth non-pv search
+ {
+ ss[ply].reduction = Depth(0);
+ value = -search(pos, ss, -alpha, newDepth, ply+1, true, threadID);
+ if (value > alpha && value < beta)
+ {
+ // When the search fails high at ply 1 while searching the first
+ // move at the root, set the flag failHighPly1. This is used for
+ // time managment: We don't want to stop the search early in
+ // such cases, because resolving the fail high at ply 1 could
+ // result in a big drop in score at the root.
+ if (ply == 1 && RootMoveNumber == 1)
+ Threads[threadID].failHighPly1 = true;
+
+ // A fail high occurred. Re-search at full window (pv search)
+ value = -search_pv(pos, ss, -beta, -alpha, newDepth, ply+1, threadID);
+ Threads[threadID].failHighPly1 = false;