X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fsearch.cpp;h=1ae6b892c8d4d245b18f4fb9d730c799a8d01d4a;hb=bb7713c8e92c9373f0294a4317101cccda0e17e5;hp=c83de5613592983953ed502ed14cd63ba2dd90ef;hpb=87f2b52aceca31f94feb4b7b47202b2d9e284609;p=stockfish diff --git a/src/search.cpp b/src/search.cpp index c83de561..1ae6b892 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -201,9 +201,6 @@ namespace { /// Namespace variables - // Book - Book OpeningBook; - // Root move list RootMoveList Rml; @@ -221,7 +218,6 @@ namespace { // Skill level adjustment int SkillLevel; bool SkillLevelEnabled; - RKISS RK; // Node counters, used only by thread[0] but try to keep in different cache // lines (64 bytes each) from the heavy multi-thread read accessed variables. @@ -322,8 +318,8 @@ void init_search() { } -/// perft() is our utility to verify move generation. All the legal moves up to -/// given depth are generated and counted and the sum returned. +/// perft() is our utility to verify move generation. All the leaf nodes up to +/// the given depth are generated and counted and the sum returned. int64_t perft(Position& pos, Depth depth) { @@ -360,6 +356,8 @@ int64_t perft(Position& pos, Depth depth) { bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) { + static Book book; + // Initialize global search-related variables StopOnPonderhit = StopRequest = QuitRequest = AspirationFailLow = SendSearchedNodes = false; NodesSincePoll = 0; @@ -380,10 +378,10 @@ bool think(Position& pos, const SearchLimits& limits, Move searchMoves[]) { // Look for a book move if (Options["OwnBook"].value()) { - if (Options["Book File"].value() != OpeningBook.name()) - OpeningBook.open(Options["Book File"].value()); + if (Options["Book File"].value() != book.name()) + book.open(Options["Book File"].value()); - Move bookMove = OpeningBook.get_move(pos, Options["Best Book Move"].value()); + Move bookMove = book.get_move(pos, Options["Best Book Move"].value()); if (bookMove != MOVE_NONE) { if (Limits.ponder) @@ -738,7 +736,7 @@ namespace { excludedMove = ss->excludedMove; posKey = excludedMove ? pos.get_exclusion_key() : pos.get_key(); - tte = TT.retrieve(posKey); + tte = TT.probe(posKey); ttMove = tte ? tte->move() : MOVE_NONE; // At PV nodes we check for exact scores, while at non-PV nodes we check for @@ -874,7 +872,7 @@ namespace { ss->skipNullMove = false; ttMove = ss->bestMove; - tte = TT.retrieve(posKey); + tte = TT.probe(posKey); } split_point_start: // At split points actual search starts from here @@ -1279,7 +1277,7 @@ split_point_start: // At split points actual search starts from here // Transposition table lookup. At PV nodes, we don't use the TT for // pruning, but only for move ordering. - tte = TT.retrieve(pos.get_key()); + tte = TT.probe(pos.get_key()); ttMove = (tte ? tte->move() : MOVE_NONE); if (!PvNode && tte && ok_to_use_TT(tte, ttDepth, beta, ss->ply)) @@ -1886,6 +1884,8 @@ split_point_start: // At split points actual search starts from here assert(MultiPV > 1); + static RKISS rk; + // Rml list is already sorted by pv_score in descending order int s; int max_s = -VALUE_INFINITE; @@ -1896,7 +1896,7 @@ split_point_start: // At split points actual search starts from here // PRNG sequence should be non deterministic for (int i = abs(get_system_time() % 50); i > 0; i--) - RK.rand(); + rk.rand(); // Choose best move. For each move's score we add two terms both dependent // on wk, one deterministic and bigger for weaker moves, and one random, @@ -1910,7 +1910,7 @@ split_point_start: // At split points actual search starts from here break; // This is our magical formula - s += ((max - s) * wk + var * (RK.rand() % wk)) / 128; + s += ((max - s) * wk + var * (rk.rand() % wk)) / 128; if (s > max_s) { @@ -1987,7 +1987,7 @@ split_point_start: // At split points actual search starts from here pos.do_move(pv[0], *st++); - while ( (tte = TT.retrieve(pos.get_key())) != NULL + while ( (tte = TT.probe(pos.get_key())) != NULL && tte->move() != MOVE_NONE && pos.move_is_legal(tte->move()) && ply < PLY_MAX @@ -2017,7 +2017,7 @@ split_point_start: // At split points actual search starts from here do { k = pos.get_key(); - tte = TT.retrieve(k); + tte = TT.probe(k); // Don't overwrite existing correct entries if (!tte || tte->move() != pv[ply]) @@ -2084,7 +2084,7 @@ split_point_start: // At split points actual search starts from here firstCall = false; return rm != Rml.end() ? rm->pv[0] : MOVE_NONE; - }; + } } // namespace