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

Accurate pv: update pv in sync with alpha

This allow us to avoid checking for child.

bench: 7712200
This commit is contained in:
Marco Costalba 2014-11-17 15:47:35 +01:00
parent 3fbe5ed06f
commit 7a18e16fd4

View file

@ -900,7 +900,8 @@ moves_loop: // When in check and at SpNode search starts from here
{ {
rm.score = value; rm.score = value;
rm.pv.resize(1); rm.pv.resize(1);
for (int i = 0; (ss+1)->pv && (ss+1)->pv[i] != MOVE_NONE; ++i)
for (int i = 0; (ss+1)->pv[i] != MOVE_NONE; ++i)
rm.pv.push_back((ss+1)->pv[i]); rm.pv.push_back((ss+1)->pv[i]);
// We record how often the best move has been changed in each // We record how often the best move has been changed in each
@ -924,15 +925,17 @@ moves_loop: // When in check and at SpNode search starts from here
{ {
bestMove = SpNode ? splitPoint->bestMove = move : move; bestMove = SpNode ? splitPoint->bestMove = move : move;
if (PvNode && !RootNode)
{
update_pv(ss->pv, move, (ss+1)->pv);
if (SpNode)
update_pv(splitPoint->ss->pv, move, (ss+1)->pv);
}
if (PvNode && value < beta) // Update alpha! Always alpha < beta if (PvNode && value < beta) // Update alpha! Always alpha < beta
{
alpha = SpNode ? splitPoint->alpha = value : value; alpha = SpNode ? splitPoint->alpha = value : value;
if (!RootNode)
{
update_pv(ss->pv, move, (ss+1)->pv);
if (SpNode)
update_pv(splitPoint->ss->pv, move, (ss+1)->pv);
}
}
else else
{ {
assert(value >= beta); // Fail high assert(value >= beta); // Fail high
@ -1242,7 +1245,7 @@ moves_loop: // When in check and at SpNode search starts from here
void update_pv(Move* pv, Move move, Move* child) { void update_pv(Move* pv, Move move, Move* child) {
for (*pv++ = move; child && *child != MOVE_NONE; ) for (*pv++ = move; *child != MOVE_NONE; )
*pv++ = *child++; *pv++ = *child++;
*pv = MOVE_NONE; *pv = MOVE_NONE;
} }