- bool can_return_tt(const TTEntry* tte, Depth depth, Value beta, int ply);
- bool connected_threat(const Position& pos, Move m, Move threat);
- Value refine_eval(const TTEntry* tte, Value defaultEval, int ply);
- void update_history(const Position& pos, Move move, Depth depth, Move movesSearched[], int moveCount);
- void do_skill_level(Move* best, Move* ponder);
-
- int elapsed_search_time(int set = 0);
- string score_to_uci(Value v, Value alpha = -VALUE_INFINITE, Value beta = VALUE_INFINITE);
- string speed_to_uci(int64_t nodes);
- string pv_to_uci(const Move pv[], int pvNum, bool chess960);
- string pretty_pv(Position& pos, int depth, Value score, int time, Move pv[]);
- string depth_to_uci(Depth depth);
- void wait_for_stop_or_ponderhit();
-
- // 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<bool SpNode> 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) {}
- };
-
- // 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, SearchStack* 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];
-
- if (type_of(pos.piece_on(move_from(m))) == PAWN)
- {
- Color c = pos.side_to_move();
- if (relative_rank(c, move_to(m)) == RANK_7)
- {
- result += PawnPushTo7thExtension[PvNode];
- *dangerous = true;
- }
- if (pos.pawn_is_passed(c, move_to(m)))
- {
- result += PassedPawnExtension[PvNode];
- *dangerous = true;
- }