X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=21aa4f92069dbcbbf7997b73364b641444fc9ed2;hp=8414e32901b769bd9ec1a93989478923063ab12d;hb=4634be8ba6176e71579fa01f5fd2c74e41eedad6;hpb=ecec7dbf894ae76fb44750ffe429496fb05fcceb diff --git a/src/search.cpp b/src/search.cpp index 8414e329..21aa4f92 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -60,11 +60,10 @@ namespace { struct IterationInfoType { - IterationInfoType(Value v = Value(0), Value sv = Value(0), bool fh = false, bool fl = false) - : value(v), speculatedValue(sv), failHigh(fh), failLow(fl) {} + IterationInfoType(Value v = Value(0), Value sv = Value(0)) + : value(v), speculatedValue(sv) {} Value value, speculatedValue; - bool failHigh, failLow; }; @@ -712,13 +711,14 @@ namespace { // Search to the current depth Value value = root_search(p, ss, rml, alpha, beta); - if (AbortSearch) - break; // Value cannot be trusted. Break out immediately! // Write PV to transposition table, in case the relevant entries have // been overwritten during the search. TT.insert_pv(p, ss[0].pv); + if (AbortSearch) + break; // Value cannot be trusted. Break out immediately! + //Save info about search result Value speculatedValue; bool fHigh = false; @@ -735,6 +735,7 @@ namespace { } else if (value <= alpha) { + assert(value == alpha); assert(delta < 0); fLow = true; @@ -744,7 +745,7 @@ namespace { speculatedValue = value; speculatedValue = Min(Max(speculatedValue, -VALUE_INFINITE), VALUE_INFINITE); - IterationInfo[Iteration] = IterationInfoType(value, speculatedValue, fHigh, fLow); + IterationInfo[Iteration] = IterationInfoType(value, speculatedValue); // Erase the easy move if it differs from the new best move if (ss[0].pv[0] != EasyMove) @@ -857,7 +858,6 @@ namespace { Value root_search(Position &pos, SearchStack ss[], RootMoveList &rml, Value alpha, Value beta) { - //FIXME: Implement bestValue Value oldAlpha = alpha; Value value; Bitboard dcCandidates = pos.discovered_check_candidates(pos.side_to_move()); @@ -867,8 +867,11 @@ namespace { { if (alpha >= beta) { + // We failed high, invalidate and skip next moves, leave node-counters + // and beta-counters as they are and quickly return, we will try to do + // a research at the next iteration with a bigger aspiration window. rml.set_move_score(i, -VALUE_INFINITE); - continue; // Leave node-counters and beta-counters as they are + continue; } int64_t nodes; Move move; @@ -951,7 +954,7 @@ namespace { rml.set_move_score(i, -VALUE_INFINITE); else { - // New best move! + // PV move or new best move! // Update PV rml.set_move_score(i, value); @@ -2507,7 +2510,7 @@ namespace { return; bool overTime = t > AbsoluteMaxSearchTime - || (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime && !FailLow) //FIXME: BUG?? + || (RootMoveNumber == 1 && t > MaxSearchTime + ExtraSearchTime && !FailLow) //FIXME: We are not checking any problem flags, BUG? || ( !FailHigh && !FailLow && !fail_high_ply_1() && !Problem && t > 6*(MaxSearchTime + ExtraSearchTime));