X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=ad13c4ba304c1a898d0a5684504d68c7e7fee47b;hp=3e6e38bd1273e4a94e67c39403ffb5448d697610;hb=67f88f5e3e4ee6e4b49151173c2898253178506f;hpb=e5c3effdb1fee10a694e493773e62f433e642406 diff --git a/src/search.cpp b/src/search.cpp index 3e6e38bd..ad13c4ba 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -154,10 +154,10 @@ void Search::init() { /// Search::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. -static size_t perft(Position& pos, Depth depth) { +static uint64_t perft(Position& pos, Depth depth) { StateInfo st; - size_t cnt = 0; + uint64_t cnt = 0; CheckInfo ci(pos); const bool leaf = depth == 2 * ONE_PLY; @@ -170,7 +170,7 @@ static size_t perft(Position& pos, Depth depth) { return cnt; } -size_t Search::perft(Position& pos, Depth depth) { +uint64_t Search::perft(Position& pos, Depth depth) { return depth > ONE_PLY ? ::perft(pos, depth) : MoveList(pos).size(); } @@ -320,7 +320,7 @@ namespace { while (++depth <= MAX_PLY && !Signals.stop && (!Limits.depth || depth <= Limits.depth)) { // Age out PV variability metric - BestMoveChanges *= 0.8; + BestMoveChanges *= 0.5; // Save the last iteration's scores before first PV line is searched and // all the move scores except the (new) PV are set to -VALUE_INFINITE. @@ -429,11 +429,10 @@ namespace { if (depth > 4 && depth < 50 && PVSize == 1) TimeMgr.pv_instability(BestMoveChanges); - // Stop the search if only one legal move is available or most - // of the available time has been used. We probably don't have - // enough time to search the first move at the next iteration anyway. + // Stop the search if only one legal move is available or all + // of the available time has been used. if ( RootMoves.size() == 1 - || IterationTime > (TimeMgr.available_time() * 62) / 100) + || IterationTime > TimeMgr.available_time() ) stop = true; if (stop) @@ -513,7 +512,7 @@ namespace { { // Step 2. Check for aborted search and immediate draw if (Signals.stop || pos.is_draw() || ss->ply > MAX_PLY) - return DrawValue[pos.side_to_move()]; + return ss->ply > MAX_PLY && !inCheck ? evaluate(pos) : DrawValue[pos.side_to_move()]; // Step 3. Mate distance pruning. Even if we mate at the next move our score // would be at best mate_in(ss->ply+1), but if alpha is already bigger because @@ -595,7 +594,7 @@ namespace { // Step 6. Razoring (skipped when in check) if ( !PvNode && depth < 4 * ONE_PLY - && eval + razor_margin(depth) < beta + && eval + razor_margin(depth) <= alpha && ttMove == MOVE_NONE && abs(beta) < VALUE_MATE_IN_MAX_PLY && !pos.pawn_on_7th(pos.side_to_move())) @@ -770,7 +769,11 @@ moves_loop: // When in check and at SpNode search starts from here ext = DEPTH_ZERO; captureOrPromotion = pos.capture_or_promotion(move); - givesCheck = pos.gives_check(move, ci); + + givesCheck = type_of(move) == NORMAL && !ci.dcCandidates + ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + : pos.gives_check(move, ci); + dangerous = givesCheck || type_of(move) != NORMAL || pos.advanced_pawn_push(move); @@ -1075,7 +1078,7 @@ moves_loop: // When in check and at SpNode search starts from here // Check for an instant draw or if the maximum ply has been reached if (pos.is_draw() || ss->ply > MAX_PLY) - return DrawValue[pos.side_to_move()]; + return ss->ply > MAX_PLY && !InCheck ? evaluate(pos) : DrawValue[pos.side_to_move()]; // Decide whether or not to include checks: this fixes also the type of // TT entry depth that we are going to use. Note that in qsearch we use @@ -1150,7 +1153,9 @@ moves_loop: // When in check and at SpNode search starts from here { assert(is_ok(move)); - givesCheck = pos.gives_check(move, ci); + givesCheck = type_of(move) == NORMAL && !ci.dcCandidates + ? ci.checkSq[type_of(pos.piece_on(from_sq(move)))] & to_sq(move) + : pos.gives_check(move, ci); // Futility pruning if ( !PvNode @@ -1622,9 +1627,8 @@ void check_time() { Time::point elapsed = Time::now() - SearchTime; bool stillAtFirstMove = Signals.firstRootMove && !Signals.failedLowAtRoot - && ( elapsed > TimeMgr.available_time() - || ( elapsed > (TimeMgr.available_time() * 62) / 100 - && elapsed > IterationTime * 1.4)); + && elapsed > TimeMgr.available_time() + && elapsed > IterationTime * 1.4; bool noMoreTime = elapsed > TimeMgr.maximum_time() - 2 * TimerThread::Resolution || stillAtFirstMove;