+ // In case of a SpNode we use split point's shared MovePicker object as moves source
+ template<> struct MovePickerExt<true> : public MovePicker {
+
+ MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, Stack* ss, Value b)
+ : MovePicker(p, ttm, d, h, ss, b), mp(ss->sp->mp) {}
+
+ Move get_next_move() { return mp->get_next_move(); }
+ MovePicker* mp;
+ };
+
+ // Overload operator<<() to make it easier to print moves in a coordinate
+ // notation compatible with UCI protocol.
+ std::ostream& operator<<(std::ostream& os, Move m) {
+
+ bool chess960 = (os.iword(0) != 0); // See set960()
+ return os << move_to_uci(m, chess960);
+ }
+
+ // When formatting a move for std::cout we must know if we are in Chess960
+ // or not. To keep using the handy operator<<() on the move the trick is to
+ // embed this flag in the stream itself. Function-like named enum set960 is
+ // used as a custom manipulator and the stream internal general-purpose array,
+ // accessed through ios_base::iword(), is used to pass the flag to the move's
+ // operator<<() that will read it to properly format castling moves.
+ enum set960 {};
+
+ std::ostream& operator<< (std::ostream& os, const set960& f) {
+
+ os.iword(0) = int(f);
+ return os;
+ }
+
+ // extension() decides whether a move should be searched with normal depth,
+ // or with extended depth. Certain classes of moves (checking moves, in
+ // particular) are searched with bigger depth than ordinary moves and in
+ // any case are marked as 'dangerous'. Note that also if a move is not
+ // extended, as example because the corresponding UCI option is set to zero,
+ // the move is marked as 'dangerous' so, at least, we avoid to prune it.
+ template <bool PvNode>
+ FORCE_INLINE Depth extension(const Position& pos, Move m, bool captureOrPromotion,
+ bool moveIsCheck, bool* dangerous) {
+ assert(m != MOVE_NONE);
+
+ Depth result = DEPTH_ZERO;
+ *dangerous = moveIsCheck;
+
+ if (moveIsCheck && pos.see_sign(m) >= 0)
+ result += CheckExtension[PvNode];