X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=e63d72e85e4d1e08602701e3c006ca17aae0718d;hp=f4e1da977990f18d2b77e988cbbc4c1c0798370e;hb=9dc6d270fc207d6715578b57a1cdf655527ec5fe;hpb=4b88bea4fcd5c4cb931610f97460615dd71ff35b diff --git a/src/search.cpp b/src/search.cpp index f4e1da97..e63d72e8 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -948,8 +948,8 @@ moves_loop: // When in check, search starts from here && pos.see_ge(move)) extension = ONE_PLY; - else if ( pos.can_castle(us) // Extension for king moves that change castling rights - && type_of(movedPiece) == KING) + // Extension if castling + else if (type_of(move) == CASTLING) extension = ONE_PLY; // Calculate new depth for this move @@ -1190,6 +1190,12 @@ moves_loop: // When in check, search starts from here // Extra penalty for a quiet TT move in previous ply when it gets refuted if ((ss-1)->moveCount == 1 && !pos.captured_piece()) update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY)); + + // Extra penalty for killer move in previous ply when it gets refuted + else if ( (ss-1)->killers[0] + && (ss-1)->currentMove == (ss-1)->killers[0] + && !pos.captured_piece()) + update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth)); } // Bonus for prior countermove that caused the fail low else if ( (depth >= 3 * ONE_PLY || PvNode) @@ -1395,21 +1401,15 @@ moves_loop: // When in check, search starts from here if (value > alpha) { + bestMove = move; + if (PvNode) // Update pv even in fail-high case update_pv(ss->pv, move, (ss+1)->pv); if (PvNode && value < beta) // Update alpha here! - { alpha = value; - bestMove = move; - } - else // Fail high - { - tte->save(posKey, value_to_tt(value, ss->ply), BOUND_LOWER, - ttDepth, move, ss->staticEval); - - return value; - } + else + break; // Fail high } } } @@ -1420,7 +1420,8 @@ moves_loop: // When in check, search starts from here return mated_in(ss->ply); // Plies to mate from the root tte->save(posKey, value_to_tt(bestValue, ss->ply), - PvNode && bestValue > oldAlpha ? BOUND_EXACT : BOUND_UPPER, + bestValue >= beta ? BOUND_LOWER : + PvNode && bestValue > oldAlpha ? BOUND_EXACT : BOUND_UPPER, ttDepth, bestMove, ss->staticEval); assert(bestValue > -VALUE_INFINITE && bestValue < VALUE_INFINITE);