1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-05-01 09:13:08 +00:00

Implement 'old' multipv search.

It seems to be a waste of time to loop through all remaining root moves
after finishing each PV line. This patch skips this until we have reached
the last PV line (this is the way it was done in Glaurung and very early
versions of Stockfish).

No functional change in Single PV mode.

MultiPV=3 STC and LTC tests
LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 3113 W: 1248 L: 1064 D: 801

LLR: 2.95 (-2.94,2.94) [0.00,5.00]
Total: 2260 W: 848 L: 679 D: 733

Bench: 5023629
This commit is contained in:
joergoster 2018-01-31 18:23:57 +01:00 committed by Stéphane Nicolet
parent 83c828f31e
commit 44a7db0f9a
2 changed files with 17 additions and 9 deletions

View file

@ -297,7 +297,7 @@ void Thread::search() {
mainThread->bestMoveChanges = 0; mainThread->bestMoveChanges = 0;
} }
size_t multiPV = Options["MultiPV"]; multiPV = Options["MultiPV"];
Skill skill(Options["Skill Level"]); Skill skill(Options["Skill Level"]);
// When playing with strength handicap enable MultiPV search that we will // When playing with strength handicap enable MultiPV search that we will
@ -802,13 +802,21 @@ moves_loop: // When in check search starts from here
if (move == excludedMove) if (move == excludedMove)
continue; continue;
if (rootNode)
{
// At root obey the "searchmoves" option and skip moves not listed in Root // At root obey the "searchmoves" option and skip moves not listed in Root
// Move List. As a consequence any illegal move is also skipped. In MultiPV // Move List. As a consequence any illegal move is also skipped.
// mode we also skip PV moves which have been already searched. if (!std::count(thisThread->rootMoves.begin() + thisThread->PVIdx,
if (rootNode && !std::count(thisThread->rootMoves.begin() + thisThread->PVIdx,
thisThread->rootMoves.end(), move)) thisThread->rootMoves.end(), move))
continue; continue;
// In MultiPV mode we not only skip PV moves which have already been searched,
// but also any other move except we have reached the last PV line.
if ( thisThread->PVIdx + 1 < thisThread->multiPV
&& move != ttMove)
continue;
}
ss->moveCount = ++moveCount; ss->moveCount = ++moveCount;
if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000) if (rootNode && thisThread == Threads.main() && Time.elapsed() > 3000)
@ -1527,7 +1535,7 @@ string UCI::pv(const Position& pos, Depth depth, Value alpha, Value beta) {
int elapsed = Time.elapsed() + 1; int elapsed = Time.elapsed() + 1;
const RootMoves& rootMoves = pos.this_thread()->rootMoves; const RootMoves& rootMoves = pos.this_thread()->rootMoves;
size_t PVIdx = pos.this_thread()->PVIdx; size_t PVIdx = pos.this_thread()->PVIdx;
size_t multiPV = std::min((size_t)Options["MultiPV"], rootMoves.size()); size_t multiPV = pos.this_thread()->multiPV;
uint64_t nodesSearched = Threads.nodes_searched(); uint64_t nodesSearched = Threads.nodes_searched();
uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0); uint64_t tbHits = Threads.tb_hits() + (TB::RootInTB ? rootMoves.size() : 0);

View file

@ -60,7 +60,7 @@ public:
Pawns::Table pawnsTable; Pawns::Table pawnsTable;
Material::Table materialTable; Material::Table materialTable;
Endgames endgames; Endgames endgames;
size_t PVIdx; size_t PVIdx, multiPV;
int selDepth, nmp_ply, nmp_odd; int selDepth, nmp_ply, nmp_odd;
std::atomic<uint64_t> nodes, tbHits; std::atomic<uint64_t> nodes, tbHits;