Skip to content

Commit

Permalink
simplify cpcm bonus
Browse files Browse the repository at this point in the history
bench 991449
  • Loading branch information
xu-shawn committed Nov 23, 2024
1 parent f11053a commit 47fc0b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
19 changes: 8 additions & 11 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,10 +593,9 @@ Value Search::Worker::search(
// Step 2. Check for aborted search and immediate draw
if (threads.stop.load(std::memory_order_relaxed) || pos.is_draw(ss->ply)
|| ss->ply >= MAX_PLY)
return (ss->ply >= MAX_PLY && !ss->inCheck)
? evaluate(networks[numaAccessToken], pos, refreshTable,
thisThread->optimism[us])
: value_draw(thisThread->nodes);
return (ss->ply >= MAX_PLY && !ss->inCheck) ? evaluate(
networks[numaAccessToken], pos, refreshTable, thisThread->optimism[us])
: value_draw(thisThread->nodes);

// Step 3. Mate distance pruning. Even if we mate at the next move our score
// would be at best mate_in(ss->ply + 1), but if alpha is already bigger because
Expand Down Expand Up @@ -889,8 +888,7 @@ Value Search::Worker::search(
// Prefetch the TT entry for the resulting position
prefetch(tt.first_entry(pos.key_after(move)));

ss->currentMove = move;
ss->capturedPiece = captured;
ss->currentMove = move;
ss->continuationHistory =
&this->continuationHistory[ss->inCheck][true][pos.moved_piece(move)][move.to_sq()];
ss->continuationCorrectionHistory =
Expand Down Expand Up @@ -1139,8 +1137,7 @@ 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->capturedPiece = pos.piece_on(move.to_sq());
ss->currentMove = move;
ss->continuationHistory =
&thisThread->continuationHistory[ss->inCheck][capture][movedPiece][move.to_sq()];
ss->continuationCorrectionHistory =
Expand Down Expand Up @@ -1405,7 +1402,8 @@ Value Search::Worker::search(
else if (priorCapture && prevSq != SQ_NONE)
{
// bonus for prior countermoves that caused the fail low
Piece capturedPiece = (ss - 1)->capturedPiece;
Piece capturedPiece = pos.captured_piece();
assert(capturedPiece != NO_PIECE);
thisThread->captureHistory[pos.piece_on(prevSq)][prevSq][type_of(capturedPiece)]
<< stat_bonus(depth) * 2;
}
Expand Down Expand Up @@ -1654,8 +1652,7 @@ 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->capturedPiece = pos.piece_on(move.to_sq());
ss->currentMove = move;
ss->continuationHistory =
&thisThread
->continuationHistory[ss->inCheck][capture][pos.moved_piece(move)][move.to_sq()];
Expand Down
3 changes: 1 addition & 2 deletions src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct Stack {
CorrectionHistory<PieceTo>* continuationCorrectionHistory;
int ply;
Move currentMove;
Piece capturedPiece;
Move excludedMove;
Value staticEval;
int statScore;
Expand Down Expand Up @@ -357,4 +356,4 @@ class Worker {

} // namespace Stockfish

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

0 comments on commit 47fc0b0

Please sign in to comment.