1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 08:43:09 +00:00

Simplify aspiration window loop

Don't open the window in case we find a mate score: this
will be takes care with next patch.

No functional change.
This commit is contained in:
Marco Costalba 2013-06-30 10:32:09 +02:00
parent 203fdc9ac1
commit 6f079ae720

View file

@ -296,9 +296,12 @@ namespace {
Value bestValue, alpha, beta, delta; Value bestValue, alpha, beta, delta;
memset(ss-1, 0, 4 * sizeof(Stack)); memset(ss-1, 0, 4 * sizeof(Stack));
depth = BestMoveChanges = 0;
bestValue = delta = -VALUE_INFINITE;
(ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains (ss-1)->currentMove = MOVE_NULL; // Hack to skip update gains
depth = BestMoveChanges = 0;
bestValue = delta = alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
TT.new_search(); TT.new_search();
History.clear(); History.clear();
Gains.clear(); Gains.clear();
@ -328,18 +331,13 @@ namespace {
// MultiPV loop. We perform a full root search for each PV line // MultiPV loop. We perform a full root search for each PV line
for (PVIdx = 0; PVIdx < PVSize; PVIdx++) for (PVIdx = 0; PVIdx < PVSize; PVIdx++)
{ {
// Set aspiration window default width // Reset aspiration window starting size
if (depth >= 5 && abs(RootMoves[PVIdx].prevScore) < VALUE_KNOWN_WIN) if (depth >= 5)
{ {
delta = Value(16); delta = Value(16);
alpha = RootMoves[PVIdx].prevScore - delta; alpha = RootMoves[PVIdx].prevScore - delta;
beta = RootMoves[PVIdx].prevScore + delta; beta = RootMoves[PVIdx].prevScore + delta;
} }
else
{
alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
}
// Start with a small aspiration window and, in case of fail high/low, // Start with a small aspiration window and, in case of fail high/low,
// research with bigger window until not failing high/low anymore. // research with bigger window until not failing high/low anymore.
@ -368,33 +366,26 @@ namespace {
// In case of failing high/low increase aspiration window and // In case of failing high/low increase aspiration window and
// research, otherwise exit the loop. // research, otherwise exit the loop.
if (bestValue > alpha && bestValue < beta) if (bestValue >= beta)
beta += delta;
else if (bestValue <= alpha)
{
alpha -= delta;
Signals.failedLowAtRoot = true;
Signals.stopOnPonderhit = false;
}
else
break; break;
delta += delta / 2;
assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
// Give some update (without cluttering the UI) before to research // Give some update (without cluttering the UI) before to research
if (Time::now() - SearchTime > 3000) if (Time::now() - SearchTime > 3000)
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl; sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
if (abs(bestValue) >= VALUE_KNOWN_WIN)
{
alpha = -VALUE_INFINITE;
beta = VALUE_INFINITE;
}
else if (bestValue >= beta)
{
beta += delta;
delta += delta / 2;
}
else
{
Signals.failedLowAtRoot = true;
Signals.stopOnPonderhit = false;
alpha -= delta;
delta += delta / 2;
}
assert(alpha >= -VALUE_INFINITE && beta <= VALUE_INFINITE);
} }
// Sort the PV lines searched so far and update the GUI // Sort the PV lines searched so far and update the GUI