#define attacks (rawAttacks + 23)
static int attackKey, rawAttacks[13*22];
+int depthLimit = MAXPLY;
int
MoveGen (int stm, MoveStack *m, int castle)
Search (int stm, int alpha, int beta, StackFrame *ff, int depth, int reduction, int maxDepth)
{
MoveStack m; StackFrame f; HashEntry *entry;
- int oldSP = moveSP, *pvStart = pvPtr;
+ int oldSP = moveSP, *pvStart = pvPtr, oldLimit = depthLimit;
int killer1 = killers[ply][0], killer2 = killers[ply][1], hashMove;
int bestNr, bestScore, startAlpha, startScore, resultDepth, iterDepth=0, originalReduction = reduction;
int hit, hashKeyH, ran=0, ipMask=0;
if(curEval >= beta) { ff->depth = 1; moveSP = oldSP; return curEval; } // stand-pat cutoff
alpha = startScore = curEval; maxDepth = 0; // we will not fail low, so no extra iterations
}
- if(maxDepth <= 0 && board[toDecode[hashMove&255]] == 0) hashMove = 0;
+ if(maxDepth <= 0) {
+ if(board[toDecode[hashMove&255]] == 0) hashMove = 0;
+#ifdef IDQS
+ if(ply >= depthLimit) { ff->depth = 1; moveSP = oldSP; return curEval + 150; } // hit depth limit; give hefty stm bonus
+ if(depthLimit == MAXPLY) depthLimit = ply+10; // we just entered pure QS; set up depth limit
+#endif
+ }
} else if(curEval >= beta && f.checker == CK_NONE) {
int nullDepth = depth - 3;
if(nullDepth < 0) nullDepth = 0;
bonus += bonus >> 1;
int newEval = curEval + bonus;
if(newEval > alpha) {
- if(newEval >= beta) { ff->depth = 1; moveSP = oldSP; return newEval; } // stand-pat cutoff
+ if(newEval >= beta) { ff->depth = 1; moveSP = oldSP; depthLimit = oldLimit; return newEval; } // stand-pat cutoff
alpha = startScore = newEval; maxDepth = 0; // we will not fail low, so no extra iterations
}
}
printf("%d:%d:%d %2d. %08x %c%d%c%d %6d %6d %6d\n",ply,depth,iterDepth,curMove,m,(m>>8&255)%22+'a',(m>>8&255)/22+1,toDecode[m&255]%22+'a',toDecode[m&255]/22+1,f.pstEval,score,bestScore);
}
- if(abortFlag) { moveSP = oldSP; return -INF; }
+ if(abortFlag) { moveSP = oldSP; depthLimit = oldLimit; return -INF; }
// minimaxing
if(f.depth < resultDepth) resultDepth = f.depth;
if(PATH || f.hashKey == 0x1348708590)printf("%d:%d Hash store %16llx, d=%d, checker=%x move=%s\n",ply,depth,f.hashKey,resultDepth,entry->checker,MoveToText(entry->move));
// return results
- moveSP = oldSP; pvPtr = pvStart;
+ moveSP = oldSP; pvPtr = pvStart; depthLimit = oldLimit;
ff->depth = resultDepth + 1 + originalReduction; // report valid depth as seen from parent
return bestScore;
}