It is a non functional change, but because
we now skip copying of pv[] in SpNode, patch
has been tested for regression with 3 threads:
STC
LLR: 2.96 (-2.94,2.94) [-3.00,1.00]
Total: 54668 W: 9873 L: 9809 D: 34986
No functional change.
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_pv(Move* pv, Move move, Move* child);
+ void update_pv(Move* pv, Move move, Move* childPv);
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))))
{
+ (ss+1)->pv[0] = MOVE_NONE;
+
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)
{
rm.score = value;
rm.pv.resize(1);
{
rm.score = value;
rm.pv.resize(1);
- for (int i = 0; (ss+1)->pv && (ss+1)->pv[i] != MOVE_NONE; ++i)
- rm.pv.push_back((ss+1)->pv[i]);
+
+ assert((ss+1)->pv);
+
+ for (Move* m = (ss+1)->pv; *m != MOVE_NONE; ++m)
+ rm.pv.push_back(*m);
// 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
{
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 && !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;
+ if (PvNode) // Update pv even in fail-high case
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
- // update_pv() copies child node pv[] adding current move
+ // update_pv() adds current move and appends child pv[]
- void update_pv(Move* pv, Move move, Move* child) {
+ void update_pv(Move* pv, Move move, Move* childPv) {
- for (*pv++ = move; child && *child != MOVE_NONE; )
- *pv++ = *child++;
+ for (*pv++ = move; childPv && *childPv != MOVE_NONE; )
+ *pv++ = *childPv++;
/// all non-pv moves.
struct RootMove {
/// all non-pv moves.
struct RootMove {
- RootMove(Move m) : score(-VALUE_INFINITE), prevScore(-VALUE_INFINITE) {
- pv.push_back(m); pv.push_back(MOVE_NONE);
- }
+ RootMove(Move m) : score(-VALUE_INFINITE), prevScore(-VALUE_INFINITE), pv(1, m) {}
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
bool operator==(const Move& m) const { return pv[0] == m; }
bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort
bool operator==(const Move& m) const { return pv[0] == m; }