Skip to content

Commit

Permalink
Remove Killers
Browse files Browse the repository at this point in the history
The removal of killers on line 1774 resulted in a substantial decrease
in pre-LMR history average, so a negative history fill is applied to
counter it.

Passed Non-regression STC (vs official-stockfish#5513):
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 21984 W: 5886 L: 5645 D: 10453
Ptnml(0-2): 80, 2492, 5628, 2691, 101
https://tests.stockfishchess.org/tests/view/66a095894ff211be9d4ecb9d

Passed Non-regression LTC (vs official-stockfish#5513):
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 95430 W: 24141 L: 23995 D: 47294
Ptnml(0-2): 97, 10537, 26298, 10689, 94
https://tests.stockfishchess.org/tests/view/66a11c8d4ff211be9d4ecbf8

closes official-stockfish#5517

Bench: 1660869
  • Loading branch information
xu-shawn authored and Disservin committed Jul 28, 2024
1 parent af802da commit 2343f71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
34 changes: 7 additions & 27 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,8 @@ Value value_to_tt(Value v, int ply);
Value value_from_tt(Value v, int ply, int r50c);
void update_pv(Move* pv, Move move, const Move* childPv);
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
void update_killer(Stack* ss, Move move);
void update_quiet_histories(
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
void update_quiet_stats(
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
void update_all_stats(const Position& pos,
Stack* ss,
Search::Worker& workerThread,
Expand Down Expand Up @@ -222,7 +219,7 @@ void Search::Worker::iterative_deepening() {

// Allocate stack with extra size to allow access from (ss - 7) to (ss + 2):
// (ss - 7) is needed for update_continuation_histories(ss - 1) which accesses (ss - 6),
// (ss + 2) is needed for initialization of cutOffCnt and killers.
// (ss + 2) is needed for initialization of cutOffCnt.
Stack stack[MAX_PLY + 10] = {};
Stack* ss = stack + 7;

Expand Down Expand Up @@ -490,7 +487,7 @@ void Search::Worker::clear() {
for (StatsType c : {NoCaptures, Captures})
for (auto& to : continuationHistory[inCheck][c])
for (auto& h : to)
h->fill(-58);
h->fill(-658);

for (size_t i = 1; i < reductions.size(); ++i)
reductions[i] = int((18.62 + std::log(size_t(options["Threads"])) / 2) * std::log(i));
Expand Down Expand Up @@ -584,7 +581,6 @@ Value Search::Worker::search(
assert(0 <= ss->ply && ss->ply < MAX_PLY);

bestMove = Move::none();
(ss + 1)->killer = Move::none();
(ss + 2)->cutoffCnt = 0;
Square prevSq = ((ss - 1)->currentMove).is_ok() ? ((ss - 1)->currentMove).to_sq() : SQ_NONE;
ss->statScore = 0;
Expand Down Expand Up @@ -615,7 +611,7 @@ Value Search::Worker::search(
{
// Bonus for a quiet ttMove that fails high (~2 Elo)
if (!ttCapture)
update_quiet_stats(pos, ss, *this, ttData.move, stat_bonus(depth));
update_quiet_histories(pos, ss, *this, ttData.move, stat_bonus(depth));

// Extra penalty for early quiet moves of
// the previous ply (~1 Elo on STC, ~2 Elo on LTC)
Expand Down Expand Up @@ -1754,7 +1750,7 @@ void update_all_stats(const Position& pos,

if (!pos.capture_stage(bestMove))
{
update_quiet_stats(pos, ss, workerThread, bestMove, quietMoveBonus);
update_quiet_histories(pos, ss, workerThread, bestMove, quietMoveBonus);

// Decrease stats for all non-best quiet moves
for (Move move : quietsSearched)
Expand All @@ -1767,12 +1763,9 @@ void update_all_stats(const Position& pos,
captureHistory[moved_piece][bestMove.to_sq()][captured] << quietMoveBonus;
}

// Extra penalty for a quiet early move that was not a TT move or
// main killer move in previous ply when it gets refuted.
if (prevSq != SQ_NONE
&& ((ss - 1)->moveCount == 1 + (ss - 1)->ttHit
|| ((ss - 1)->currentMove == (ss - 1)->killer))
&& !pos.captured_piece())
// Extra penalty for a quiet early move that was not a TT move in
// previous ply when it gets refuted.
if (prevSq != SQ_NONE && ((ss - 1)->moveCount == 1 + (ss - 1)->ttHit) && !pos.captured_piece())
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus);

// Decrease stats for all non-best capture moves
Expand Down Expand Up @@ -1802,11 +1795,6 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
}

// Updates move sorting heuristics
void update_killer(Stack* ss, Move move) {

// Update killers
ss->killer = move;
}

void update_quiet_histories(
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {
Expand All @@ -1820,14 +1808,6 @@ void update_quiet_histories(
workerThread.pawnHistory[pIndex][pos.moved_piece(move)][move.to_sq()] << bonus / 2;
}

// Updates move sorting heuristics
void update_quiet_stats(
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {

update_killer(ss, move);
update_quiet_histories(pos, ss, workerThread, move, bonus);
}

}

// When playing with strength handicap, choose the best move among a set of
Expand Down
1 change: 0 additions & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ struct Stack {
int ply;
Move currentMove;
Move excludedMove;
Move killer;
Value staticEval;
int statScore;
int moveCount;
Expand Down

0 comments on commit 2343f71

Please sign in to comment.