void id_loop(Position& pos);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
void id_loop(Position& pos);
Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply);
void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
string uci_pv(const Position& pos, Depth depth, Value alpha, Value beta);
void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt);
string uci_pv(const Position& pos, Depth depth, Value alpha, Value beta);
// parent node fail low with value <= alpha and to try another move.
if (PvNode && (moveCount == 1 || (value > alpha && (RootNode || value < beta))))
{
// parent node fail low with value <= alpha and to try another move.
if (PvNode && (moveCount == 1 || (value > alpha && (RootNode || value < beta))))
{
value = newDepth < ONE_PLY ?
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
value = newDepth < ONE_PLY ?
givesCheck ? -qsearch<PV, true>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
: -qsearch<PV, false>(pos, ss+1, -beta, -alpha, DEPTH_ZERO)
// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
// We record how often the best move has been changed in each
// iteration. This information is used for time management: When
- if (PvNode && !RootNode)
- {
- update_pv(ss->pv, move, (ss+1)->pv);
- if (SpNode)
- update_pv(splitPoint->ss->pv, move, (ss+1)->pv);
- }
+ if (PvNode && !RootNode) // Update pv even in fail-high case
+ update_pv(SpNode ? splitPoint->ss->pv : ss->pv, move, (ss+1)->pv);
if (PvNode && value < beta) // Update alpha! Always alpha < beta
alpha = SpNode ? splitPoint->alpha = value : value;
if (PvNode && value < beta) // Update alpha! Always alpha < beta
alpha = SpNode ? splitPoint->alpha = value : value;
update_pv(ss->pv, move, (ss+1)->pv);
if (PvNode && value < beta) // Update alpha here! Always alpha < beta
update_pv(ss->pv, move, (ss+1)->pv);
if (PvNode && value < beta) // Update alpha here! Always alpha < beta