+
+ // A dispatcher to choose among different move sources according to the type of node
+ template<bool SpNode, bool Root> struct MovePickerExt;
+
+ // In Root nodes use RootMoveList Rml as source
+ template<> struct MovePickerExt<false, true> {
+
+ MovePickerExt(const Position&, Move, Depth, const History&, SearchStack*, Value)
+ : rm(Rml->begin()), firstCall(true) {}
+
+ Move get_next_move() {
+
+ if (!firstCall)
+ ++rm;
+ else
+ firstCall = false;
+
+ return rm != Rml->end() ? rm->pv[0] : MOVE_NONE;
+ }
+ int number_of_evasions() const { return (int)Rml->size(); }
+
+ RootMoveList::iterator rm;
+ bool firstCall;
+ };
+
+ // In SpNodes use split point's shared MovePicker as move source
+ template<> struct MovePickerExt<true, false> {
+
+ MovePickerExt(const Position&, Move, Depth, const History&, SearchStack* ss, Value)
+ : mp(ss->sp->mp) {}
+
+ Move get_next_move() { return mp->get_next_move(); }
+ int number_of_evasions() const { return mp->number_of_evasions(); }
+
+ RootMoveList::iterator rm; // Dummy, never used
+ MovePicker* mp;
+ };
+
+ // Normal case, create and use a MovePicker object as source
+ template<> struct MovePickerExt<false, false> : public MovePicker {
+
+ MovePickerExt(const Position& p, Move ttm, Depth d, const History& h,
+ SearchStack* ss, Value beta) : MovePicker(p, ttm, d, h, ss, beta) {}
+
+ RootMoveList::iterator rm; // Dummy, never used
+ };
+
+} // namespace