X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=77acd89e39b12310d5333708de19c5c85c7a883f;hp=51c2a27d330a7b12626185d74100b5bbc0bcbc6f;hb=98352a5e84096c906d5ecc1aeb2fca8745e173c2;hpb=348f8241041a26cd9458beb8098306099f44a46a diff --git a/src/search.cpp b/src/search.cpp index 51c2a27d..77acd89e 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -30,7 +30,6 @@ #include "evaluate.h" #include "history.h" #include "misc.h" -#include "move.h" #include "movegen.h" #include "movepick.h" #include "search.h" @@ -39,12 +38,6 @@ #include "tt.h" #include "ucioption.h" -using std::cout; -using std::endl; -using std::string; -using Search::Signals; -using Search::Limits; - namespace Search { volatile SignalsType Signals; @@ -53,6 +46,11 @@ namespace Search { Position RootPosition; } +using std::cout; +using std::endl; +using std::string; +using namespace Search; + namespace { // Set to true to force running with one thread. Used for debugging @@ -187,10 +185,10 @@ namespace { Move id_loop(Position& pos, Move rootMoves[], Move* ponderMove); template - Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth); + Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth); template - Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth); + Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth); bool check_is_dangerous(Position &pos, Move move, Value futilityBase, Value beta, Value *bValue); bool connected_moves(const Position& pos, Move m1, Move m2); @@ -214,14 +212,14 @@ namespace { // we simply create and use a standard MovePicker object. template struct MovePickerExt : public MovePicker { - MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, SearchStack* ss, Value b) + MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, Stack* 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 : public MovePicker { - MovePickerExt(const Position& p, Move ttm, Depth d, const History& h, SearchStack* ss, Value b) + 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(); } @@ -353,10 +351,9 @@ int64_t Search::perft(Position& pos, Depth depth) { } -/// think() is the external interface to Stockfish's search, and is called when -/// the program receives the UCI 'go' command. It initializes various global -/// variables, and calls id_loop(). It returns false when a "quit" command is -/// received during the search. +/// think() is the external interface to Stockfish's search, and is called by the +/// main thread when the program receives the UCI 'go' command. It searches from +/// RootPosition and at the end prints the "bestmove" to output. void Search::think() { @@ -489,7 +486,7 @@ namespace { Move id_loop(Position& pos, Move rootMoves[], Move* ponderMove) { - SearchStack ss[PLY_MAX_PLUS_2]; + Stack ss[PLY_MAX_PLUS_2]; Value bestValues[PLY_MAX_PLUS_2]; int bestMoveChanges[PLY_MAX_PLUS_2]; int depth, aspirationDelta; @@ -498,7 +495,7 @@ namespace { bool bestMoveNeverChanged = true; // Initialize stuff before a new search - memset(ss, 0, 4 * sizeof(SearchStack)); + memset(ss, 0, 4 * sizeof(Stack)); TT.new_search(); H.clear(); *ponderMove = bestMove = skillBest = skillPonder = MOVE_NONE; @@ -710,7 +707,7 @@ namespace { // here: This is taken care of after we return from the split point. template - Value search(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth) { + Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) { const bool PvNode = (NT == PV || NT == Root || NT == SplitPointPV || NT == SplitPointRoot); const bool SpNode = (NT == SplitPointPV || NT == SplitPointNonPV || NT == SplitPointRoot); @@ -1299,7 +1296,7 @@ split_point_start: // At split points actual search starts from here // less than ONE_PLY). template - Value qsearch(Position& pos, SearchStack* ss, Value alpha, Value beta, Depth depth) { + Value qsearch(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth) { const bool PvNode = (NT == PV); @@ -2103,11 +2100,11 @@ void Thread::idle_loop(SplitPoint* sp) { assert(!do_terminate); // Copy split point position and search stack and call search() - SearchStack ss[PLY_MAX_PLUS_2]; + Stack ss[PLY_MAX_PLUS_2]; SplitPoint* tsp = splitPoint; Position pos(*tsp->pos, threadID); - memcpy(ss, tsp->ss - 1, 4 * sizeof(SearchStack)); + memcpy(ss, tsp->ss - 1, 4 * sizeof(Stack)); (ss+1)->sp = tsp; if (tsp->nodeType == Root)