// We're ready to start thinking. Call the iterative deepening loop function
Value v = id_loop(pos, searchMoves);
// We're ready to start thinking. Call the iterative deepening loop function
Value v = id_loop(pos, searchMoves);
// searchMoves are verified, copied, scored and sorted
RootMoveList rml(p, searchMoves);
// searchMoves are verified, copied, scored and sorted
RootMoveList rml(p, searchMoves);
int prevDelta1 = IterationInfo[Iteration - 1].speculatedValue - IterationInfo[Iteration - 2].speculatedValue;
int prevDelta2 = IterationInfo[Iteration - 2].speculatedValue - IterationInfo[Iteration - 3].speculatedValue;
int prevDelta1 = IterationInfo[Iteration - 1].speculatedValue - IterationInfo[Iteration - 2].speculatedValue;
int prevDelta2 = IterationInfo[Iteration - 2].speculatedValue - IterationInfo[Iteration - 3].speculatedValue;
- int delta = Max(abs(prevDelta1) + abs(prevDelta2) / 2, 16);
-
- delta = (delta + 7) / 8 * 8; // Round to match grainSize
- AspirationDelta = delta;
+ AspirationDelta = Max(abs(prevDelta1) + abs(prevDelta2) / 2, 16);
+ AspirationDelta = (AspirationDelta + 7) / 8 * 8; // Round to match grainSize
- alpha = Max(IterationInfo[Iteration - 1].value - delta, -VALUE_INFINITE);
- beta = Min(IterationInfo[Iteration - 1].value + delta, VALUE_INFINITE);
+ alpha = Max(IterationInfo[Iteration - 1].value - AspirationDelta, -VALUE_INFINITE);
+ beta = Min(IterationInfo[Iteration - 1].value + AspirationDelta, VALUE_INFINITE);
Value root_search(Position& pos, SearchStack ss[], RootMoveList& rml, Value& oldAlpha, Value& beta) {
Value root_search(Position& pos, SearchStack ss[], RootMoveList& rml, Value& oldAlpha, Value& beta) {
- if (!isCheck)
- ss[0].eval = evaluate(pos, ei, 0);
- else
- ss[0].eval = VALUE_NONE;
+ ss[0].eval = !isCheck ? evaluate(pos, ei, 0) : VALUE_NONE;
- bool moveIsCheck = pos.move_is_check(move);
- bool captureOrPromotion = pos.move_is_capture_or_promotion(move);
- bool dangerous;
- depth = (Iteration - 2) * OnePly + InitialDepth;
+ moveIsCheck = pos.move_is_check(move);
+ captureOrPromotion = pos.move_is_capture_or_promotion(move);
+ depth = (Iteration - 2) * OnePly + InitialDepth;
ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, false, false, &dangerous);
newDepth = depth + ext;
ext = extension(pos, move, true, captureOrPromotion, moveIsCheck, false, false, &dangerous);
newDepth = depth + ext;
// We are failing high and going to do a research. It's important to update score
// before research in case we run out of time while researching.
// We are failing high and going to do a research. It's important to update score
// before research in case we run out of time while researching.
nodes_searched(), value, type, ss[0].pv) << endl;
}
nodes_searched(), value, type, ss[0].pv) << endl;
}
ss[ply].reduction = reduction(moveCount, LogLimit, BaseReduction, Gradient);
if (ss[ply].reduction)
{
ss[ply].reduction = reduction(moveCount, LogLimit, BaseReduction, Gradient);
if (ss[ply].reduction)
{
moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0);
moves[count].score = -qsearch(pos, ss, -VALUE_INFINITE, VALUE_INFINITE, Depth(0), 1, 0);
// reduction() returns reduction in plies based on moveCount and depth.
// Reduction is always at least one ply.
// reduction() returns reduction in plies based on moveCount and depth.
// Reduction is always at least one ply.
- Depth reduction(int moveCount, float logLimit, float baseReduction, float gradient) {
+ Depth reduction(int moveCount, float logLimit, float baseReduction, float gradient) {