Skip to content

Commit

Permalink
Use continutation history for captures (qsearch)
Browse files Browse the repository at this point in the history
Bench: 3043258
  • Loading branch information
snicolet committed Jan 6, 2019
1 parent f69106f commit 9bfbee8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/movepick.cpp
Expand Up @@ -107,9 +107,16 @@ void MovePicker::score() {

for (auto& m : *this)
if (Type == CAPTURES)
{
m.value = PieceValue[MG][pos.piece_on(to_sq(m))]
+ (*captureHistory)[pos.moved_piece(m)][to_sq(m)][type_of(pos.piece_on(to_sq(m)))] / 8;

if (stage == QCAPTURE_INIT)
m.value += ( (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
+ (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)] ) / 2;
}

else if (Type == QUIETS)
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
+ (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
Expand Down
27 changes: 13 additions & 14 deletions src/search.cpp
Expand Up @@ -652,24 +652,25 @@ namespace {
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
: (tte->bound() & BOUND_UPPER)))
{
// If ttMove is quiet, update move sorting heuristics on TT hit
// Update move sorting heuristics on TT hit
if (ttMove)
{
if (ttValue >= beta)
{
if (!pos.capture_or_promotion(ttMove))
update_quiet_stats(pos, ss, ttMove, nullptr, 0, stat_bonus(depth));

// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
if ( ((ss-1)->moveCount == 1 || (ss-1)->currentMove == (ss-1)->killers[0])
&& !pos.captured_piece())
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
// Extra penalty for a TT move or main killer move in previous ply when it gets refuted
if ((ss-1)->moveCount == 1 || (ss-1)->currentMove == (ss-1)->killers[0])
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
}
// Penalty for a quiet ttMove that fails low
else if (!pos.capture_or_promotion(ttMove))
// Penalty for a ttMove that fails low
else
{
int penalty = -stat_bonus(depth);
thisThread->mainHistory[us][from_to(ttMove)] << penalty;
if (!pos.capture_or_promotion(ttMove))
thisThread->mainHistory[us][from_to(ttMove)] << penalty;

update_continuation_histories(ss, pos.moved_piece(ttMove), to_sq(ttMove), penalty);
}
}
Expand Down Expand Up @@ -1202,15 +1203,13 @@ namespace {

update_capture_stats(pos, bestMove, capturesSearched, captureCount, stat_bonus(depth + ONE_PLY));

// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
if ( ((ss-1)->moveCount == 1 || ((ss-1)->currentMove == (ss-1)->killers[0]))
&& !pos.captured_piece())
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));
// Extra penalty for a TT move or main killer move in previous ply when it gets refuted
if ((ss-1)->moveCount == 1 || ((ss-1)->currentMove == (ss-1)->killers[0]))
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -stat_bonus(depth + ONE_PLY));

}
// Bonus for prior countermove that caused the fail low
else if ( (depth >= 3 * ONE_PLY || PvNode)
&& !pos.captured_piece())
else if (depth >= 3 * ONE_PLY || PvNode)
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, stat_bonus(depth));

if (PvNode)
Expand Down

0 comments on commit 9bfbee8

Please sign in to comment.