MoveStack m; StackFrame f; HashEntry *entry;
int oldSP = moveSP, *pvStart = pvPtr;
int killer1 = killers[ply][0], killer2 = killers[ply][1], hashMove;
- int bestNr, bestScore, startAlpha, startScore, resultDepth, iterDepth=0;
+ int bestNr, bestScore, startAlpha, startScore, resultDepth, iterDepth=0, originalReduction = reduction;
int hit, hashKeyH, ran=0;
int curEval, score;
// check test
if(f.checker == CK_UNKNOWN) CheckTest(stm, ff, &f); // test for check if hash did not supply it
- if(f.checker != CK_NONE) depth++, maxDepth++, reduction = 0; // extend check evasions
+ if(f.checker != CK_NONE) depth++, maxDepth++, reduction = originalReduction = 0; // extend check evasions
else if(depth > 3) {
if(depth - reduction < 3) reduction = depth - 3; // never reduce to below 3 ply
depth -= reduction;
- } else reduction = 0;
+ } else reduction = originalReduction = 0;
if(PATH)printf("%d:%d {%d,%d} max=%d eval=%d check=%02x,%d,%d\n",ply,depth,alpha,beta,maxDepth,curEval,f.checker,f.checkDir,f.checkDist);
// stand pat or null move
startAlpha = alpha; startScore = -INF;
deprec[ply] = maxDepth << 16 | depth << 8; path[ply++] = 0;
score = -Search(stm, -alpha-1, -alpha, &f, nullDepth, 0, nullDepth);
ply--;
- if(score >= beta) { ff->depth = f.depth + 2; moveSP = oldSP; return beta + 1; }
+ if(score >= beta) { ff->depth = f.depth + originalReduction + 3; moveSP = oldSP; return beta + 1; }
}
// move generation
// self-deepening
if(resultDepth > iterDepth) iterDepth = resultDepth; // unexpectedly deep result (from hashed daughters?)
- if(reduction && iterDepth == depth) depth += reduction, reduction = 0; // no fail high, start unreduced re-search on behalf of parent
+ if(reduction && iterDepth == depth) depth += reduction, originalReduction = reduction = 0; // no fail high, start unreduced re-search on behalf of parent
if(PATH)printf("%d:%d:%d iter end, max=%d, alpha=%d start=%d\n", ply, depth,iterDepth, maxDepth, alpha, startAlpha);
if(iterDepth >= depth && alpha > startAlpha ) break; // move is PV; nominal depth suffices
alpha = startAlpha; // reset alpha for next iteration
// return results
moveSP = oldSP; pvPtr = pvStart;
- ff->depth = resultDepth + 1 + reduction; // report valid depth as seen from parent
+ ff->depth = resultDepth + 1 + originalReduction; // report valid depth as seen from parent
return bestScore;
}