Skip to content

Commit

Permalink
Refactor prior countermove bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
Ergodice authored and PikaCat-OuO committed Jan 27, 2025
1 parent d555602 commit 4f011f7
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1293,23 +1293,22 @@ Value Search::Worker::search(
int bonusScale = (184 * (depth > 6) + 80 * !allNode + 152 * ((ss - 1)->moveCount > 11)
+ 77 * (!ss->inCheck && bestValue <= ss->staticEval - 157)
+ 169 * (!(ss - 1)->inCheck && bestValue <= -(ss - 1)->staticEval - 99)
+ 80 * ((ss - 1)->isTTMove));
+ 80 * ((ss - 1)->isTTMove) + std::min(-(ss - 1)->statScore / 79, 234));

// Proportional to "how much damage we have to undo"
bonusScale += std::min(-(ss - 1)->statScore / 79, 234);

bonusScale = std::max(bonusScale, 0);

const int scaledBonus = stat_bonus(depth) * bonusScale / 32;
const int scaledBonus = stat_bonus(depth) * bonusScale;

update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq,
scaledBonus * 416 / 1024);
scaledBonus * 416 / 32768);

thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()] << scaledBonus * 212 / 1024;
thisThread->mainHistory[~us][((ss - 1)->currentMove).from_to()]
<< scaledBonus * 212 / 32768;

if (type_of(pos.piece_on(prevSq)) != PAWN)
thisThread->pawnHistory[pawn_structure_index(pos)][pos.piece_on(prevSq)][prevSq]
<< scaledBonus * 1073 / 1024;
<< scaledBonus * 1073 / 32768;
}

else if (priorCapture && prevSq != SQ_NONE)
Expand Down Expand Up @@ -1349,14 +1348,8 @@ Value Search::Worker::search(
auto bonus = std::clamp(int(bestValue - ss->staticEval) * depth / 8,
-CORRECTION_HISTORY_LIMIT / 4, CORRECTION_HISTORY_LIMIT / 4);
thisThread->pawnCorrectionHistory[us][pawn_structure_index<Correction>(pos)]
<<<<<<< HEAD
<< bonus * 148 / 128;
thisThread->majorPieceCorrectionHistory[us][major_piece_index(pos)] << bonus * 185 / 128;
thisThread->minorPieceCorrectionHistory[us][minor_piece_index(pos)] << bonus * 101 / 128;
=======
<< bonus * 114 / 128;
thisThread->minorPieceCorrectionHistory[us][minor_piece_index(pos)] << bonus * 146 / 128;
>>>>>>> 831cb01c (Remove major corrhist)
thisThread->nonPawnCorrectionHistory[WHITE][non_pawn_index<WHITE>(pos)][us]
<< bonus * nonPawnWeight / 128;
thisThread->nonPawnCorrectionHistory[BLACK][non_pawn_index<BLACK>(pos)][us]
Expand Down

0 comments on commit 4f011f7

Please sign in to comment.