X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.h;h=20cfd4741fab7ca35c2e55979e6794eecb373409;hp=25e71a845c36c201b54fbd405e7fc2587d76a656;hb=62f531254e03f946c92ad307fb68c7faa2806d16;hpb=53ab32ef0b6e47d8d962f8c1fccd32d3c22f138c diff --git a/src/search.h b/src/search.h index 25e71a84..20cfd474 100644 --- a/src/search.h +++ b/src/search.h @@ -20,7 +20,6 @@ #ifndef SEARCH_H_INCLUDED #define SEARCH_H_INCLUDED -#include #include #include #include @@ -39,6 +38,7 @@ namespace Search { struct Stack { SplitPoint* splitPoint; + Move* pv; int ply; Move currentMove; Move ttMove; @@ -46,7 +46,7 @@ struct Stack { Move killers[2]; Depth reduction; Value staticEval; - int skipNullMove; + bool skipEarlyPruning; }; @@ -56,21 +56,19 @@ struct Stack { /// all non-pv moves. struct RootMove { - RootMove(Move m) : score(-VALUE_INFINITE), prevScore(-VALUE_INFINITE) { - pv.push_back(m); pv.push_back(MOVE_NONE); - } + RootMove(Move m) : score(-VALUE_INFINITE), previousScore(-VALUE_INFINITE), pv(1, m) {} bool operator<(const RootMove& m) const { return score > m.score; } // Ascending sort bool operator==(const Move& m) const { return pv[0] == m; } - void extract_pv_from_tt(Position& pos); void insert_pv_in_tt(Position& pos); Value score; - Value prevScore; + Value previousScore; std::vector pv; }; +typedef std::vector RootMoveVector; /// The LimitsType struct stores information sent by GUI about available time /// to search the current move, maximum depth/time, if we are in analysis mode @@ -78,10 +76,15 @@ struct RootMove { struct LimitsType { - LimitsType() { std::memset(this, 0, sizeof(LimitsType)); } + LimitsType() { // Using memset on a std::vector is undefined behavior + nodes = time[WHITE] = time[BLACK] = inc[WHITE] = inc[BLACK] = movestogo = + depth = movetime = mate = infinite = ponder = 0; + } bool use_time_management() const { return !(mate | movetime | depth | nodes | infinite); } - int time[COLOR_NB], inc[COLOR_NB], movestogo, depth, nodes, movetime, mate, infinite, ponder; + std::vector searchmoves; + int time[COLOR_NB], inc[COLOR_NB], movestogo, depth, movetime, mate, infinite, ponder; + int64_t nodes; }; @@ -89,22 +92,21 @@ struct LimitsType { /// typically in an async fashion e.g. to stop the search by the GUI. struct SignalsType { - bool stopOnPonderhit, firstRootMove, stop, failedLowAtRoot; + bool stop, stopOnPonderhit, firstRootMove, failedLowAtRoot; }; typedef std::auto_ptr > StateStackPtr; extern volatile SignalsType Signals; extern LimitsType Limits; -extern std::vector RootMoves; +extern RootMoveVector RootMoves; extern Position RootPos; -extern Color RootColor; -extern Time::point SearchTime, IterationTime; +extern Time::point SearchTime; extern StateStackPtr SetupStates; -extern void init(); -extern size_t perft(Position& pos, Depth depth); -extern void think(); +void init(); +void think(); +template uint64_t perft(Position& pos, Depth depth); } // namespace Search