diff --git a/src/history.h b/src/history.h index ec245230a..f2ef7661f 100644 --- a/src/history.h +++ b/src/history.h @@ -166,6 +166,8 @@ struct CorrHistTypedef { template using CorrectionHistory = typename Detail::CorrHistTypedef::type; +using TTMoveHistory = Stats; + } // namespace Stockfish #endif // #ifndef HISTORY_H_INCLUDED diff --git a/src/search.cpp b/src/search.cpp index 5f5934a49..291b99bd1 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -580,6 +580,8 @@ void Search::Worker::clear() { minorPieceCorrectionHistory.fill(0); nonPawnCorrectionHistory.fill(0); + ttMoveHistory.fill(0); + for (auto& to : continuationCorrectionHistory) for (auto& h : to) h.fill(5); @@ -1139,7 +1141,8 @@ moves_loop: // When in check, search starts here { int corrValAdj1 = std::abs(correctionValue) / 248873; int corrValAdj2 = std::abs(correctionValue) / 255331; - int doubleMargin = 262 * PvNode - 188 * !ttCapture - corrValAdj1; + int doubleMargin = 262 * PvNode - 188 * !ttCapture - corrValAdj1 + - ttMoveHistory[pawn_structure_index(pos)][us] / 128; int tripleMargin = 88 + 265 * PvNode - 256 * !ttCapture + 93 * ss->ttPv - corrValAdj2; @@ -1430,8 +1433,15 @@ moves_loop: // When in check, search starts here // If there is a move that produces search value greater than alpha, // we update the stats of searched moves. else if (bestMove) + { update_all_stats(pos, ss, *this, bestMove, prevSq, quietsSearched, capturesSearched, depth, bestMove == ttData.move, moveCount); + if (!PvNode) + { + int bonus = (ttData.move == move) ? 800 : -600 * moveCount; + ttMoveHistory[pawn_structure_index(pos)][us] << bonus; + } + } // Bonus for prior quiet countermove that caused the fail low else if (!priorCapture && prevSq != SQ_NONE) diff --git a/src/search.h b/src/search.h index 071773f81..6ef8322a8 100644 --- a/src/search.h +++ b/src/search.h @@ -292,6 +292,8 @@ class Worker { CorrectionHistory nonPawnCorrectionHistory; CorrectionHistory continuationCorrectionHistory; + TTMoveHistory ttMoveHistory; + private: void iterative_deepening();