mirror of
https://github.com/sockspls/badfish
synced 2025-07-11 19:49:14 +00:00
Fix incorrect StateInfo
We use Position::set() to set root position across
threads. But there are some StateInfo fields (previous,
pliesFromNull, capturedPiece) that cannot be deduced
from a fen string, so set() clears them and to not lose
the info we need to backup and later restore setupStates->back().
Note that setupStates is shared by threads but is accessed
in read-only mode.
This fixes regression introduced by df6cb446ea
Tested with 3 threads at STC:
LLR: 2.95 (-2.94,2.94) [-4.00,0.00]
Total: 14436 W: 2304 L: 2196 D: 9936
Bench: 5608839
This commit is contained in:
parent
c3e964f35e
commit
232c50fed0
1 changed files with 7 additions and 5 deletions
|
@ -158,10 +158,12 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
|
||||||
if (states.get())
|
if (states.get())
|
||||||
setupStates = std::move(states); // Ownership transfer, states is now empty
|
setupStates = std::move(states); // Ownership transfer, states is now empty
|
||||||
|
|
||||||
// We use Position::set() to set root position across threads. So we
|
// We use Position::set() to set root position across threads. But there are
|
||||||
// need to save and later to restore st->previous, cleared by set().
|
// some StateInfo fields (previous, pliesFromNull, capturedPiece) that cannot
|
||||||
// Note that setupStates is shared by threads but is accessed in read-only mode.
|
// be deduced from a fen string, so set() clears them and to not lose the info
|
||||||
StateInfo* previous = setupStates->back().previous;
|
// we need to backup and later restore setupStates->back(). Note that setupStates
|
||||||
|
// is shared by threads but is accessed in read-only mode.
|
||||||
|
StateInfo tmp = setupStates->back();
|
||||||
|
|
||||||
for (Thread* th : Threads)
|
for (Thread* th : Threads)
|
||||||
{
|
{
|
||||||
|
@ -171,7 +173,7 @@ void ThreadPool::start_thinking(Position& pos, StateListPtr& states,
|
||||||
th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
|
th->rootPos.set(pos.fen(), pos.is_chess960(), &setupStates->back(), th);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupStates->back().previous = previous;
|
setupStates->back() = tmp;
|
||||||
|
|
||||||
main()->start_searching();
|
main()->start_searching();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue