mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Fix an off-by-one bug in multi pv print
We send to GUI multi-pv info after each cycle, not just once at the end of the PV loop. This is because at high depths a single root search can be very slow and we want to update the gui as soon as we have a new PV score. Idea is good but implementation is broken because sort() takes as arguments a pointer to the first element and one past the last element. So fix the bug and rename sort arguments to better reflect their meaning. Another hit by Hongzhi Cheng. Impressive! No functional change.
This commit is contained in:
parent
bbdf9e4737
commit
52f55179a8
2 changed files with 4 additions and 4 deletions
|
@ -394,7 +394,7 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the PV lines searched so far and update the GUI
|
// Sort the PV lines searched so far and update the GUI
|
||||||
sort<RootMove>(RootMoves.begin(), RootMoves.begin() + PVIdx);
|
sort<RootMove>(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -490,15 +490,15 @@ inline const std::string square_to_string(Square s) {
|
||||||
/// Our insertion sort implementation, works with pointers and iterators and is
|
/// Our insertion sort implementation, works with pointers and iterators and is
|
||||||
/// guaranteed to be stable, as is needed.
|
/// guaranteed to be stable, as is needed.
|
||||||
template<typename T, typename K>
|
template<typename T, typename K>
|
||||||
void sort(K first, K last)
|
void sort(K begin, K end)
|
||||||
{
|
{
|
||||||
T tmp;
|
T tmp;
|
||||||
K p, q;
|
K p, q;
|
||||||
|
|
||||||
for (p = first + 1; p < last; p++)
|
for (p = begin + 1; p < end; p++)
|
||||||
{
|
{
|
||||||
tmp = *p;
|
tmp = *p;
|
||||||
for (q = p; q != first && *(q-1) < tmp; --q)
|
for (q = p; q != begin && *(q-1) < tmp; --q)
|
||||||
*q = *(q-1);
|
*q = *(q-1);
|
||||||
*q = tmp;
|
*q = tmp;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue