+ // MovePickerExt template class extends MovePicker and allows to choose at compile
+ // time the proper moves source according to the type of node. In the default case
+ // we simply create and use a standard MovePicker object.
+ template<NodeType> struct MovePickerExt : public MovePicker {
+
+ MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, SearchStack* ss, Value b)
+ : MovePicker(p, ttm, d, h, ss, b) {}
+
+ RootMove& current() { assert(false); return Rml[0]; } // Dummy, needed to compile
+ };
+
+ // In case of a SpNode we use split point's shared MovePicker object as moves source
+ template<> struct MovePickerExt<SplitPointNonPV> : public MovePickerExt<NonPV> {
+
+ MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, SearchStack* ss, Value b)
+ : MovePickerExt<NonPV>(p, ttm, d, h, ss, b), mp(ss->sp->mp) {}
+
+ Move get_next_move() { return mp->get_next_move(); }
+ MovePicker* mp;
+ };
+
+ template<> struct MovePickerExt<SplitPointPV> : public MovePickerExt<SplitPointNonPV> {
+
+ MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, SearchStack* ss, Value b)
+ : MovePickerExt<SplitPointNonPV>(p, ttm, d, h, ss, b) {}
+ };
+
+ // In case of a Root node we use RootMoveList as moves source
+ template<> struct MovePickerExt<Root> : public MovePicker {
+
+ MovePickerExt(const Position&, Move, Depth, const History&, SearchStack*, Value);
+ RootMove& current() { return Rml[cur]; }
+ Move get_next_move() { return ++cur < (int)Rml.size() ? Rml[cur].pv[0] : MOVE_NONE; }
+
+ int cur;
+ };
+