Skip to content

Commit

Permalink
prior countermove bonus for capture that caused fail low
Browse files Browse the repository at this point in the history
bench 914094
  • Loading branch information
Ergodice committed Nov 23, 2024
1 parent 82b092c commit f7157b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,8 @@ Value Search::Worker::search(
// Prefetch the TT entry for the resulting position
prefetch(tt.first_entry(pos.key_after(move)));

ss->currentMove = move;
ss->currentMove = move;
ss->capturedPiece = captured;
ss->continuationHistory =
&this->continuationHistory[ss->inCheck][true][pos.moved_piece(move)][move.to_sq()];
ss->continuationCorrectionHistory =
Expand Down Expand Up @@ -1139,7 +1140,8 @@ Value Search::Worker::search(
prefetch(tt.first_entry(pos.key_after(move)));

// Update the current move (this must be done after singular extension search)
ss->currentMove = move;
ss->currentMove = move;
ss->capturedPiece = pos.piece_on(move.to_sq());
ss->continuationHistory =
&thisThread->continuationHistory[ss->inCheck][capture][movedPiece][move.to_sq()];
ss->continuationCorrectionHistory =
Expand Down Expand Up @@ -1403,6 +1405,13 @@ Value Search::Worker::search(
<< stat_bonus(depth) * bonus / 24;
}

else if (priorCapture && prevSq != SQ_NONE)
{
// bonus for prior countermoves that caused the fail low
Piece capturedPiece = (ss - 1)->capturedPiece;
thisThread->captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)]
<< stat_bonus(depth) * 2;
}
// Bonus when search fails low and there is a TT move
else if (ttData.move && !allNode)
thisThread->mainHistory[us][ttData.move.from_to()] << stat_bonus(depth) * 23 / 100;
Expand Down Expand Up @@ -1647,7 +1656,8 @@ Value Search::Worker::qsearch(Position& pos, Stack* ss, Value alpha, Value beta)
prefetch(tt.first_entry(pos.key_after(move)));

// Update the current move
ss->currentMove = move;
ss->currentMove = move;
ss->capturedPiece = pos.piece_on(move.to_sq());
ss->continuationHistory =
&thisThread
->continuationHistory[ss->inCheck][capture][pos.moved_piece(move)][move.to_sq()];
Expand Down Expand Up @@ -2167,4 +2177,4 @@ bool RootMove::extract_ponder_from_tt(const TranspositionTable& tt, Position& po
}


} // namespace Stockfish
} // namespace Stockfish
3 changes: 2 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ struct Stack {
CorrectionHistory<PieceTo>* continuationCorrectionHistory;
int ply;
Move currentMove;
Piece capturedPiece;
Move excludedMove;
Value staticEval;
int statScore;
Expand Down Expand Up @@ -356,4 +357,4 @@ class Worker {

} // namespace Stockfish

#endif // #ifndef SEARCH_H_INCLUDED
#endif // #ifndef SEARCH_H_INCLUDED

0 comments on commit f7157b0

Please sign in to comment.