X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fsearch.cpp;h=ee343fafd04033ecda0e411123f6c4671c7130a0;hp=b0e2c950fe7354c784cd14689ab7c3cbb7bed6b4;hb=8463fa479ee2841f852fdf57374b08c87b61e227;hpb=e51965aa57ddc50d04016e3622da49cf9f8e6238 diff --git a/src/search.cpp b/src/search.cpp index b0e2c950..ee343faf 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -137,7 +137,7 @@ namespace { HistoryStats History; CounterMovesHistoryStats CounterMovesHistory; GainsStats Gains; - MovesStats Countermoves, Followupmoves; + MovesStats Countermoves; template Value search(Position& pos, Stack* ss, Value alpha, Value beta, Depth depth, bool cutNode); @@ -339,8 +339,7 @@ namespace { CounterMovesHistory.clear(); Gains.clear(); Countermoves.clear(); - Followupmoves.clear(); - + size_t multiPV = Options["MultiPV"]; Skill skill(Options["Skill Level"]); @@ -595,7 +594,7 @@ namespace { { ss->currentMove = ttMove; // Can be MOVE_NONE - // If ttMove is quiet, update killers, history, counter move and followup move on TT hit + // If ttMove is quiet, update killers, history, counter move on TT hit if (ttValue >= beta && ttMove && !pos.capture_or_promotion(ttMove) && !inCheck) update_stats(pos, ss, ttMove, depth, nullptr, 0); @@ -787,11 +786,7 @@ moves_loop: // When in check and at SpNode search starts from here Move countermoves[] = { Countermoves[pos.piece_on(prevMoveSq)][prevMoveSq].first, Countermoves[pos.piece_on(prevMoveSq)][prevMoveSq].second }; - Square prevOwnMoveSq = to_sq((ss-2)->currentMove); - Move followupmoves[] = { Followupmoves[pos.piece_on(prevOwnMoveSq)][prevOwnMoveSq].first, - Followupmoves[pos.piece_on(prevOwnMoveSq)][prevOwnMoveSq].second }; - - MovePicker mp(pos, ttMove, depth, History, CounterMovesHistory, countermoves, followupmoves, ss); + MovePicker mp(pos, ttMove, depth, History, CounterMovesHistory, countermoves, ss); CheckInfo ci(pos); value = bestValue; // Workaround a bogus 'uninitialized' warning under gcc improving = ss->staticEval >= (ss-2)->staticEval @@ -964,7 +959,9 @@ moves_loop: // When in check and at SpNode search starts from here ss->reduction = reduction(improving, depth, moveCount); if ( (!PvNode && cutNode) - || History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO) + || History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO + || CounterMovesHistory[pos.piece_on(prevMoveSq)][prevMoveSq][pos.piece_on(to_sq(move))][to_sq(move)] + + History[pos.piece_on(to_sq(move))][to_sq(move)] < VALUE_ZERO) ss->reduction += ONE_PLY; if (move == countermoves[0] || move == countermoves[1]) @@ -1142,7 +1139,7 @@ moves_loop: // When in check and at SpNode search starts from here bestValue = excludedMove ? alpha : inCheck ? mated_in(ss->ply) : DrawValue[pos.side_to_move()]; - // Quiet best move: update killers, history, countermoves and followupmoves + // Quiet best move: update killers, history and countermoves else if (bestValue >= beta && !pos.capture_or_promotion(bestMove) && !inCheck) update_stats(pos, ss, bestMove, depth, quietsSearched, quietCount - 1); @@ -1402,8 +1399,8 @@ moves_loop: // When in check and at SpNode search starts from here *pv = MOVE_NONE; } - // update_stats() updates killers, history, countermoves and followupmoves - // stats after a fail-high of a quiet move. + // update_stats() updates killers, history and countermoves stats after a fail-high + // of a quiet move. void update_stats(const Position& pos, Stack* ss, Move move, Depth depth, Move* quiets, int quietsCnt) { @@ -1437,16 +1434,11 @@ moves_loop: // When in check and at SpNode search starts from here if (is_ok((ss-2)->currentMove) && (ss-1)->currentMove == (ss-1)->ttMove) { - Value bonus2 = Value(((depth+1) / ONE_PLY) * ((depth+1) / ONE_PLY)); - Square prevPrevSq = to_sq((ss-2)->currentMove); - Followupmoves.update(pos.piece_on(prevPrevSq), prevPrevSq, move); - - Square prevMoveSq = to_sq((ss-1)->currentMove); - Piece prevMovePiece = pos.piece_on(prevMoveSq); - HistoryStats& cmh2 = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq]; - cmh2.update(prevMovePiece, prevMoveSq, -bonus2); + // Extra penalty for TT move in previous ply when it gets refuted + HistoryStats& ttMoveCmh = CounterMovesHistory[pos.piece_on(prevPrevSq)][prevPrevSq]; + ttMoveCmh.update(pos.piece_on(prevSq), prevSq, -bonus - 2 * depth / ONE_PLY - 1); } }