mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-20 17:16:33 +08:00
Use if/else instead of goto
Real men jump/branch by hand...but we prefer the humble way. Moved also some uci info code where it belongs, while there. No functional change. Resolves #110
This commit is contained in:
committed by
Joona Kiiski
parent
db4b8ee000
commit
b777b17f6f
@@ -191,26 +191,19 @@ void Search::think() {
|
|||||||
sync_cout << "info depth 0 score "
|
sync_cout << "info depth 0 score "
|
||||||
<< UCI::format_value(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
|
<< UCI::format_value(RootPos.checkers() ? -VALUE_MATE : VALUE_DRAW)
|
||||||
<< sync_endl;
|
<< sync_endl;
|
||||||
|
|
||||||
goto finalize;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < Threads.size(); ++i)
|
||||||
|
Threads[i]->maxPly = 0;
|
||||||
|
|
||||||
// Reset the threads, still sleeping: will wake up at split time
|
Threads.timer->run = true;
|
||||||
for (size_t i = 0; i < Threads.size(); ++i)
|
Threads.timer->notify_one(); // Wake up the recurring timer
|
||||||
Threads[i]->maxPly = 0;
|
|
||||||
|
|
||||||
Threads.timer->run = true;
|
id_loop(RootPos); // Let's start searching !
|
||||||
Threads.timer->notify_one(); // Wake up the recurring timer
|
|
||||||
|
|
||||||
id_loop(RootPos); // Let's start searching !
|
Threads.timer->run = false;
|
||||||
|
}
|
||||||
Threads.timer->run = false; // Stop the timer
|
|
||||||
|
|
||||||
finalize:
|
|
||||||
|
|
||||||
// When search is stopped this info is not printed
|
|
||||||
sync_cout << "info nodes " << RootPos.nodes_searched()
|
|
||||||
<< " time " << Time::now() - SearchTime + 1 << sync_endl;
|
|
||||||
|
|
||||||
// When we reach the maximum depth, we can arrive here without a raise of
|
// When we reach the maximum depth, we can arrive here without a raise of
|
||||||
// Signals.stop. However, if we are pondering or in an infinite search,
|
// Signals.stop. However, if we are pondering or in an infinite search,
|
||||||
@@ -223,7 +216,6 @@ finalize:
|
|||||||
RootPos.this_thread()->wait_for(Signals.stop);
|
RootPos.this_thread()->wait_for(Signals.stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Best move could be MOVE_NONE when searching on a stalemate position
|
|
||||||
sync_cout << "bestmove " << UCI::format_move(RootMoves[0].pv[0], 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())
|
<< " ponder " << UCI::format_move(RootMoves[0].pv[1], RootPos.is_chess960())
|
||||||
<< sync_endl;
|
<< sync_endl;
|
||||||
@@ -342,9 +334,12 @@ namespace {
|
|||||||
// Sort the PV lines searched so far and update the GUI
|
// Sort the PV lines searched so far and update the GUI
|
||||||
std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
|
std::stable_sort(RootMoves.begin(), RootMoves.begin() + PVIdx + 1);
|
||||||
|
|
||||||
if ( !Signals.stop
|
if (Signals.stop)
|
||||||
&& ( PVIdx + 1 == std::min(multiPV, RootMoves.size())
|
sync_cout << "info nodes " << RootPos.nodes_searched()
|
||||||
|| Time::now() - SearchTime > 3000))
|
<< " time " << Time::now() - SearchTime << sync_endl;
|
||||||
|
|
||||||
|
else if ( PVIdx + 1 == std::min(multiPV, RootMoves.size())
|
||||||
|
|| Time::now() - SearchTime > 3000)
|
||||||
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
|
sync_cout << uci_pv(pos, depth, alpha, beta) << sync_endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user