X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=8dc695d0e83faec353c58b129577f20733f52fde;hp=294091ddd1e5da4eb02cc669368933bf06524146;hb=0a73a23dc9cdd32ebd47436fd3595279d3990209;hpb=f97c5b6909d22277f28e3dea2f146e9314d634dc diff --git a/src/search.cpp b/src/search.cpp index 294091dd..8dc695d0 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -84,7 +84,7 @@ namespace { void read_uci_options(); bool available_thread_exists(int master) const; bool thread_is_available(int slave, int master) const; - bool thread_should_stop(int threadID) const; + bool cutoff_at_splitpoint(int threadID) const; void wake_sleeping_thread(int threadID); void idle_loop(int threadID, SplitPoint* sp); @@ -1007,8 +1007,10 @@ namespace { } // Step 2. Check for aborted search and immediate draw - if ( AbortSearch || ThreadsMgr.thread_should_stop(threadID) - || pos.is_draw() || ply >= PLY_MAX - 1) + if ( AbortSearch + || ThreadsMgr.cutoff_at_splitpoint(threadID) + || pos.is_draw() + || ply >= PLY_MAX - 1) return VALUE_DRAW; // Step 3. Mate distance pruning @@ -1198,7 +1200,7 @@ split_point_start: // At split points actual search starts from here // Loop through all legal moves until no moves remain or a beta cutoff occurs while ( bestValue < beta && (move = mp.get_next_move()) != MOVE_NONE - && !ThreadsMgr.thread_should_stop(threadID)) + && !ThreadsMgr.cutoff_at_splitpoint(threadID)) { assert(move_is_ok(move)); @@ -1371,7 +1373,7 @@ split_point_start: // At split points actual search starts from here alpha = sp->alpha; } - if (value > bestValue && !(SpNode && ThreadsMgr.thread_should_stop(threadID))) + if (value > bestValue && !(SpNode && ThreadsMgr.cutoff_at_splitpoint(threadID))) { bestValue = value; @@ -1380,15 +1382,15 @@ split_point_start: // At split points actual search starts from here if (value > alpha) { - if (SpNode && (!PvNode || value >= beta)) - sp->stopRequest = true; - if (PvNode && value < beta) // We want always alpha < beta { alpha = value; + if (SpNode) sp->alpha = value; } + else if (SpNode) + sp->betaCutoff = true; if (value == value_mate_in(ply + 1)) ss->mateKiller = move; @@ -1407,7 +1409,7 @@ split_point_start: // At split points actual search starts from here && bestValue < beta && ThreadsMgr.available_thread_exists(threadID) && !AbortSearch - && !ThreadsMgr.thread_should_stop(threadID) + && !ThreadsMgr.cutoff_at_splitpoint(threadID) && Iteration <= 99) ThreadsMgr.split(pos, ss, ply, &alpha, beta, &bestValue, depth, threatMove, mateThreat, moveCount, &mp, PvNode); @@ -1423,7 +1425,7 @@ split_point_start: // At split points actual search starts from here // Step 20. Update tables // If the search is not aborted, update the transposition table, // history counters, and killer moves. - if (!SpNode && !AbortSearch && !ThreadsMgr.thread_should_stop(threadID)) + if (!SpNode && !AbortSearch && !ThreadsMgr.cutoff_at_splitpoint(threadID)) { move = bestValue <= oldAlpha ? MOVE_NONE : ss->bestMove; vt = bestValue <= oldAlpha ? VALUE_TYPE_UPPER @@ -1540,7 +1542,7 @@ split_point_start: // At split points actual search starts from here // to search the moves. Because the depth is <= 0 here, only captures, // queen promotions and checks (only if depth >= DEPTH_QS_CHECKS) will // be generated. - MovePicker mp = MovePicker(pos, ttMove, depth, H); + MovePicker mp(pos, ttMove, depth, H); CheckInfo ci(pos); // Loop through the moves until no moves remain or a beta cutoff occurs @@ -2466,17 +2468,17 @@ split_point_start: // At split points actual search starts from here } - // thread_should_stop() checks whether the thread should stop its search. - // This can happen if a beta cutoff has occurred in the thread's currently - // active split point, or in some ancestor of the current split point. + // cutoff_at_splitpoint() checks whether a beta cutoff has occurred in + // the thread's currently active split point, or in some ancestor of + // the current split point. - bool ThreadsManager::thread_should_stop(int threadID) const { + bool ThreadsManager::cutoff_at_splitpoint(int threadID) const { assert(threadID >= 0 && threadID < activeThreads); SplitPoint* sp = threads[threadID].splitPoint; - for ( ; sp && !sp->stopRequest; sp = sp->parent) {} + for ( ; sp && !sp->betaCutoff; sp = sp->parent) {} return sp != NULL; } @@ -2575,7 +2577,7 @@ split_point_start: // At split points actual search starts from here // Initialize the split point object splitPoint.parent = masterThread.splitPoint; splitPoint.master = master; - splitPoint.stopRequest = false; + splitPoint.betaCutoff = false; splitPoint.ply = ply; splitPoint.depth = depth; splitPoint.threatMove = threatMove; @@ -2709,7 +2711,7 @@ split_point_start: // At split points actual search starts from here { Move move; int score = 1000; - MovePicker mp = MovePicker(pos, MOVE_NONE, ONE_PLY, H); + MovePicker mp(pos, MOVE_NONE, ONE_PLY, H); while ((move = mp.get_next_move()) != MOVE_NONE) for (int i = 0; i < count; i++)