template <NodeType PvNode>
Depth extension(const Position& pos, Move m, bool captureOrPromotion, bool moveIsCheck, bool singleEvasion, bool mateThreat, bool* dangerous);
- void update_pv(SearchStack* ss);
- void sp_update_pv(SearchStack* pss, SearchStack* ss);
bool connected_moves(const Position& pos, Move m1, Move m2);
bool value_is_mate(Value value);
bool move_is_killer(Move m, SearchStack* ss);
void ponderhit();
void wait_for_stop_or_ponderhit();
void init_ss_array(SearchStack* ss, int size);
- void print_pv_info(const Position& pos, Move* ss, Value alpha, Value beta, Value value);
+ void print_pv_info(const Position& pos, Move pv[], Value alpha, Value beta, Value value);
#if !defined(_MSC_VER)
void *init_thread(void *threadID);
// We are failing high and going to do a research. It's important to update
// the score before research in case we run out of time while researching.
rml.set_move_score(i, value);
- update_pv(ss);
- pv[0] = ss->bestMove;
- TT.extract_pv(pos, pv, PLY_MAX);
+ ss->bestMove = move;
+ TT.extract_pv(pos, move, pv, PLY_MAX);
rml.set_move_pv(i, pv);
// Print information to the standard output
// Update PV
rml.set_move_score(i, value);
- update_pv(ss);
- pv[0] = ss->bestMove;
- TT.extract_pv(pos, pv, PLY_MAX);
+ ss->bestMove = move;
+ TT.extract_pv(pos, move, pv, PLY_MAX);
rml.set_move_pv(i, pv);
if (MultiPV == 1)
if (PvNode && value < beta) // This guarantees that always: alpha < beta
alpha = value;
- update_pv(ss);
-
if (value == value_mate_in(ply + 1))
ss->mateKiller = move;
+
+ ss->bestMove = move;
}
}
if (value > alpha)
{
alpha = value;
- update_pv(ss);
+ ss->bestMove = move;
}
}
}
if (PvNode && value < sp->beta) // This guarantees that always: sp->alpha < sp->beta
sp->alpha = value;
- sp_update_pv(sp->parentSstack, ss);
+ sp->parentSstack->bestMove = ss->bestMove = move;
}
}
}
lock_release(&(sp->lock));
}
- // update_pv() is called whenever a search returns a value > alpha.
- // It updates the PV in the SearchStack object corresponding to the
- // current node.
-
- void update_pv(SearchStack* ss) {
-
- ss->bestMove = ss->currentMove;
- }
-
-
- // sp_update_pv() is a variant of update_pv for use at split points. The
- // difference between the two functions is that sp_update_pv also updates
- // the PV at the parent node.
-
- void sp_update_pv(SearchStack* pss, SearchStack* ss) {
-
- pss->bestMove = ss->bestMove = ss->currentMove;
- }
-
// connected_moves() tests whether two moves are 'connected' in the sense
// that the first move somehow made the second move possible (for instance
// print_pv_info() prints to standard output and eventually to log file information on
// the current PV line. It is called at each iteration or after a new pv is found.
- void print_pv_info(const Position& pos, Move* pv, Value alpha, Value beta, Value value) {
+ void print_pv_info(const Position& pos, Move pv[], Value alpha, Value beta, Value value) {
cout << "info depth " << Iteration
- << " score " << value_to_string(value)
- << ((value >= beta) ? " lowerbound" :
- ((value <= alpha)? " upperbound" : ""))
+ << " score " << value_to_string(value)
+ << (value >= beta ? " lowerbound" : value <= alpha ? " upperbound" : "")
<< " time " << current_search_time()
<< " nodes " << TM.nodes_searched()
<< " nps " << nps()
<< " pv ";
- for (int j = 0; pv[j] != MOVE_NONE && j < PLY_MAX; j++)
- cout << pv[j] << " ";
+ for (Move* m = pv; *m != MOVE_NONE; m++)
+ cout << *m << " ";
cout << endl;
if (UseLogFile)
{
- ValueType type = (value >= beta ? VALUE_TYPE_LOWER
- : (value <= alpha ? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT));
+ ValueType t = value >= beta ? VALUE_TYPE_LOWER :
+ value <= alpha ? VALUE_TYPE_UPPER : VALUE_TYPE_EXACT;
LogFile << pretty_pv(pos, current_search_time(), Iteration,
- TM.nodes_searched(), value, type, pv) << endl;
+ TM.nodes_searched(), value, t, pv) << endl;
}
}