- for (hd = 1; hd < 64; ++hd) for (mc = 1; mc < 64; ++mc)
- {
- double pvRed = 0.00 + log(double(hd)) * log(double(mc)) / 3.00;
- double nonPVRed = 0.33 + log(double(hd)) * log(double(mc)) / 2.25;
+ for (int d = 1; d < 64; ++d)
+ for (int mc = 1; mc < 64; ++mc)
+ {
+ double pvRed = 0.00 + log(double(d)) * log(double(mc)) / 3.00;
+ double nonPVRed = 0.33 + log(double(d)) * log(double(mc)) / 2.25;
- Reductions[1][1][hd][mc] = int8_t( pvRed >= 1.0 ? pvRed + 0.5: 0);
- Reductions[0][1][hd][mc] = int8_t(nonPVRed >= 1.0 ? nonPVRed + 0.5: 0);
+ Reductions[1][1][d][mc] = int8_t( pvRed >= 1.0 ? pvRed + 0.5: 0);
+ Reductions[0][1][d][mc] = int8_t(nonPVRed >= 1.0 ? nonPVRed + 0.5: 0);
- Reductions[1][0][hd][mc] = Reductions[1][1][hd][mc];
- Reductions[0][0][hd][mc] = Reductions[0][1][hd][mc];
+ Reductions[1][0][d][mc] = Reductions[1][1][d][mc];
+ Reductions[0][0][d][mc] = Reductions[0][1][d][mc];
- if (Reductions[0][0][hd][mc] >= 2)
- Reductions[0][0][hd][mc] += 1;
- }
+ // Increase reduction when eval is not improving
+ if (Reductions[0][0][d][mc] >= 2)
+ Reductions[0][0][d][mc] += 1;
+ }
{
FutilityMoveCounts[0][d] = int(2.4 + 0.773 * pow(d + 0.00, 1.8));
FutilityMoveCounts[1][d] = int(2.9 + 1.045 * pow(d + 0.49, 1.8));
{
FutilityMoveCounts[0][d] = int(2.4 + 0.773 * pow(d + 0.00, 1.8));
FutilityMoveCounts[1][d] = int(2.9 + 1.045 * pow(d + 0.49, 1.8));
- sync_cout << "bestmove " << move_to_uci(RootMoves[0].pv[0], RootPos.is_chess960())
- << " ponder " << move_to_uci(RootMoves[0].pv[1], RootPos.is_chess960())
+ sync_cout << "bestmove " << UCI::format_move(RootMoves[0].pv[0], RootPos.is_chess960())
+ << " ponder " << UCI::format_move(RootMoves[0].pv[1], RootPos.is_chess960())
int depth;
Value bestValue, alpha, beta, delta;
int depth;
Value bestValue, alpha, beta, delta;
multiPV = std::max(multiPV, skill.candidates_size());
// Iterative deepening loop until requested to stop or target depth reached
multiPV = std::max(multiPV, skill.candidates_size());
// Iterative deepening loop until requested to stop or target depth reached
alpha = std::max(bestValue - delta, -VALUE_INFINITE);
Signals.failedLowAtRoot = true;
Signals.stopOnPonderhit = false;
}
else if (bestValue >= beta)
alpha = std::max(bestValue - delta, -VALUE_INFINITE);
Signals.failedLowAtRoot = true;
Signals.stopOnPonderhit = false;
}
else if (bestValue >= beta)
// Sort the PV lines searched so far and update the GUI
std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
// Sort the PV lines searched so far and update the GUI
std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
}
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
}
Move ttMove, move, excludedMove, bestMove;
Depth ext, newDepth, predictedDepth;
Value bestValue, value, ttValue, eval, nullValue, futilityValue;
Move ttMove, move, excludedMove, bestMove;
Depth ext, newDepth, predictedDepth;
Value bestValue, value, ttValue, eval, nullValue, futilityValue;
- bool inCheck, givesCheck, pvMove, singularExtensionNode, improving;
+ bool inCheck, givesCheck, singularExtensionNode, improving;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, quietCount;
bool captureOrPromotion, dangerous, doFullDepthSearch;
int moveCount, quietCount;
- if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY)
- return ss->ply > MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
+ if (Signals.stop || pos.is_draw() || ss->ply >= MAX_PLY)
+ return ss->ply >= MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply+1), but if alpha is already bigger because
// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply+1), but if alpha is already bigger because
+ assert(0 <= ss->ply && ss->ply < MAX_PLY);
+
+ ss->currentMove = ss->ttMove = (ss+1)->excludedMove = bestMove = MOVE_NONE;
+ (ss+1)->skipNullMove = false; (ss+1)->reduction = DEPTH_ZERO;
+ (ss+2)->killers[0] = (ss+2)->killers[1] = MOVE_NONE;
+
// Step 4. Transposition table lookup
// We don't want the score of a partial search to overwrite a previous full search
// TT value, so we use a different position key in case of an excluded move.
// Step 4. Transposition table lookup
// We don't want the score of a partial search to overwrite a previous full search
// TT value, so we use a different position key in case of an excluded move.
if (thisThread == Threads.main() && Time::now() - SearchTime > 3000)
sync_cout << "info depth " << depth
if (thisThread == Threads.main() && Time::now() - SearchTime > 3000)
sync_cout << "info depth " << depth
// Step 15. Reduced depth search (LMR). If the move fails high it will be
// re-searched at full depth.
if ( depth >= 3 * ONE_PLY
// Step 15. Reduced depth search (LMR). If the move fails high it will be
// re-searched at full depth.
if ( depth >= 3 * ONE_PLY
// 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.
// 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.
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)
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)
RootMove& rm = *std::find(RootMoves.begin(), RootMoves.end(), move);
// PV move or new best move ?
RootMove& rm = *std::find(RootMoves.begin(), RootMoves.end(), move);
// PV move or new best move ?
// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
// the best move changes frequently, we allocate some more time.
// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
// the best move changes frequently, we allocate some more time.
- if (pos.is_draw() || ss->ply > MAX_PLY)
- return ss->ply > MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
+ if (pos.is_draw() || ss->ply >= MAX_PLY)
+ return ss->ply >= MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()];
+
+ assert(0 <= ss->ply && ss->ply < MAX_PLY);
// Decide whether or not to include checks: this fixes also the type of
// TT entry depth that we are going to use. Note that in qsearch we use
// Decide whether or not to include checks: this fixes also the type of
// TT entry depth that we are going to use. Note that in qsearch we use
- << " score " << (i == PVIdx ? score_to_uci(v, alpha, beta) : score_to_uci(v))
+ << " multipv " << i + 1
+ << " score " << (i == PVIdx ? UCI::format_value(v, alpha, beta) : UCI::format_value(v))
Position pos(*sp->pos, this);
std::memcpy(ss-2, sp->ss-2, 5 * sizeof(Stack));
Position pos(*sp->pos, this);
std::memcpy(ss-2, sp->ss-2, 5 * sizeof(Stack));
// Loop across all split points and sum accumulated SplitPoint nodes plus
// all the currently active positions nodes.
// Loop across all split points and sum accumulated SplitPoint nodes plus
// all the currently active positions nodes.
- bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution
- || stillAtFirstMove;
-
- if ( (Limits.use_time_management() && noMoreTime)
- || (Limits.movetime && elapsed >= Limits.movetime)
- || (Limits.nodes && nodes >= Limits.nodes))
- Signals.stop = true;
+ if (nodes >= Limits.nodes)
+ Signals.stop = true;
+ }