@@ -334,7 +334,8 @@ void Thread::search() {
334334
335335 std::memset (ss-7 , 0 , 10 * sizeof (Stack));
336336 for (int i = 7 ; i > 0 ; i--)
337- (ss-i)->continuationHistory = &this ->continuationHistory [NO_PIECE][0 ]; // Use as sentinel
337+ (ss-i)->continuationHistory = &this ->continuationHistory [0 ][NO_PIECE][0 ]; // Use as a sentinel
338+
338339 ss->pv = pv;
339340
340341 bestValue = delta = alpha = -VALUE_INFINITE;
@@ -595,12 +596,13 @@ namespace {
595596 Value bestValue, value, ttValue, eval, maxValue;
596597 bool ttHit, ttPv, inCheck, givesCheck, improving, doLMR;
597598 bool captureOrPromotion, doFullDepthSearch, moveCountPruning, ttCapture;
598- Piece movedPiece;
599+ Piece movedPiece, priorCapture ;
599600 int moveCount, captureCount, quietCount, singularLMR;
600601
601602 // Step 1. Initialize node
602603 Thread* thisThread = pos.this_thread ();
603604 inCheck = pos.checkers ();
605+ priorCapture = pos.captured_piece ();
604606 Color us = pos.side_to_move ();
605607 moveCount = captureCount = quietCount = singularLMR = ss->moveCount = 0 ;
606608 bestValue = -VALUE_INFINITE;
@@ -680,7 +682,7 @@ namespace {
680682 update_quiet_stats (pos, ss, ttMove, nullptr , 0 , stat_bonus (depth));
681683
682684 // Extra penalty for early quiet moves of the previous ply
683- if ((ss-1 )->moveCount <= 2 && !pos. captured_piece () )
685+ if ((ss-1 )->moveCount <= 2 && !priorCapture )
684686 update_continuation_histories (ss-1 , pos.piece_on (prevSq), prevSq, -stat_bonus (depth + 1 ));
685687 }
686688 // Penalty for a quiet ttMove that fails low
@@ -814,7 +816,7 @@ namespace {
814816 Depth R = (835 + 70 * depth) / 256 + std::min (int (eval - beta) / 185 , 3 );
815817
816818 ss->currentMove = MOVE_NULL;
817- ss->continuationHistory = &thisThread->continuationHistory [NO_PIECE][0 ];
819+ ss->continuationHistory = &thisThread->continuationHistory [0 ][ NO_PIECE][0 ];
818820
819821 pos.do_null_move (st);
820822
@@ -865,7 +867,7 @@ namespace {
865867 probCutCount++;
866868
867869 ss->currentMove = move;
868- ss->continuationHistory = &thisThread->continuationHistory [pos.moved_piece (move)][to_sq (move)];
870+ ss->continuationHistory = &thisThread->continuationHistory [!!priorCapture][ pos.moved_piece (move)][to_sq (move)];
869871
870872 assert (depth >= 5 );
871873
@@ -1066,7 +1068,7 @@ namespace {
10661068
10671069 // Update the current move (this must be done after singular extension search)
10681070 ss->currentMove = move;
1069- ss->continuationHistory = &thisThread->continuationHistory [movedPiece][to_sq (move)];
1071+ ss->continuationHistory = &thisThread->continuationHistory [!!priorCapture][ movedPiece][to_sq (move)];
10701072
10711073 // Step 15. Make the move
10721074 pos.do_move (move, st, givesCheck);
@@ -1279,13 +1281,13 @@ namespace {
12791281
12801282 // Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
12811283 if ( ((ss-1 )->moveCount == 1 || ((ss-1 )->currentMove == (ss-1 )->killers [0 ]))
1282- && !pos. captured_piece () )
1284+ && !priorCapture )
12831285 update_continuation_histories (ss-1 , pos.piece_on (prevSq), prevSq, -stat_bonus (depth + 1 ));
12841286
12851287 }
12861288 // Bonus for prior countermove that caused the fail low
12871289 else if ( (depth >= 3 || PvNode)
1288- && !pos. captured_piece () )
1290+ && !priorCapture )
12891291 update_continuation_histories (ss-1 , pos.piece_on (prevSq), prevSq, stat_bonus (depth));
12901292
12911293 if (PvNode)
@@ -1321,6 +1323,7 @@ namespace {
13211323 Move ttMove, move, bestMove;
13221324 Depth ttDepth;
13231325 Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
1326+ Piece priorCapture;
13241327 bool ttHit, pvHit, inCheck, givesCheck, evasionPrunable;
13251328 int moveCount;
13261329
@@ -1335,6 +1338,7 @@ namespace {
13351338 (ss+1 )->ply = ss->ply + 1 ;
13361339 bestMove = MOVE_NONE;
13371340 inCheck = pos.checkers ();
1341+ priorCapture = pos.captured_piece ();
13381342 moveCount = 0 ;
13391343
13401344 // Check for an immediate draw or maximum ply reached
@@ -1472,7 +1476,7 @@ namespace {
14721476 }
14731477
14741478 ss->currentMove = move;
1475- ss->continuationHistory = &thisThread->continuationHistory [pos.moved_piece (move)][to_sq (move)];
1479+ ss->continuationHistory = &thisThread->continuationHistory [!!priorCapture][ pos.moved_piece (move)][to_sq (move)];
14761480
14771481 // Make and search the move
14781482 pos.do_move (move, st, givesCheck);
0 commit comments