Skip to content

Commit

Permalink
removed second killer move
Browse files Browse the repository at this point in the history
STC with movepicker rewrite:

LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 46656 W: 12208 L: 11995 D: 22453
Ptnml(0-2): 203, 5461, 11777, 5694, 193
https://tests.stockfishchess.org/tests/view/668d98a15034141ae5999e68

Earlier version passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 468896 W: 120999 L: 120054 D: 227843
Ptnml(0-2): 1207, 55209, 120639, 56218, 1175
https://tests.stockfishchess.org/tests/view/668b17d2cf91c430fca58630

Earlier version passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 550524 W: 139553 L: 139877 D: 271094
Ptnml(0-2): 333, 61646, 151616, 61346, 321
https://tests.stockfishchess.org/tests/view/668b2e04cf91c430fca586b1

closes official-stockfish/Stockfish#5472

bench 1234309

Co-authored-by: rn5f107s2 <[email protected]>
  • Loading branch information
2 people authored and vondele committed Jul 11, 2024
1 parent 6135a0e commit 8d1e414
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
28 changes: 12 additions & 16 deletions src/movepick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

#include <algorithm>
#include <cassert>
#include <iterator>
#include <utility>

#include "bitboard.h"
Expand All @@ -35,7 +34,7 @@ enum Stages {
MAIN_TT,
CAPTURE_INIT,
GOOD_CAPTURE,
REFUTATION,
KILLER,
QUIET_INIT,
GOOD_QUIET,
BAD_CAPTURE,
Expand Down Expand Up @@ -91,14 +90,14 @@ MovePicker::MovePicker(const Position& p,
const CapturePieceToHistory* cph,
const PieceToHistory** ch,
const PawnHistory* ph,
const Move* killers) :
Move km) :
pos(p),
mainHistory(mh),
captureHistory(cph),
continuationHistory(ch),
pawnHistory(ph),
ttMove(ttm),
refutations{{killers[0], 0}, {killers[1], 0}},
killer{km, 0},
depth(d) {
assert(d > 0);

Expand Down Expand Up @@ -268,19 +267,17 @@ Move MovePicker::next_move(bool skipQuiets) {
}))
return *(cur - 1);

// Prepare the pointers to loop over the refutations array
cur = std::begin(refutations);
endMoves = std::end(refutations);

++stage;
[[fallthrough]];

case REFUTATION :
if (select<Next>([&]() {
return *cur != Move::none() && !pos.capture_stage(*cur) && pos.pseudo_legal(*cur);
}))
return *(cur - 1);
case KILLER :
// increment it before so if we aren't stuck here indefinitely
++stage;

if (killer != ttMove && killer != Move::none() && !pos.capture_stage(killer)
&& pos.pseudo_legal(killer))
return killer;

[[fallthrough]];

case QUIET_INIT :
Expand All @@ -297,8 +294,7 @@ Move MovePicker::next_move(bool skipQuiets) {
[[fallthrough]];

case GOOD_QUIET :
if (!skipQuiets
&& select<Next>([&]() { return *cur != refutations[0] && *cur != refutations[1]; }))
if (!skipQuiets && select<Next>([&]() { return *cur != killer; }))
{
if ((cur - 1)->value > -7998 || (cur - 1)->value <= quiet_threshold(depth))
return *(cur - 1);
Expand Down Expand Up @@ -327,7 +323,7 @@ Move MovePicker::next_move(bool skipQuiets) {

case BAD_QUIET :
if (!skipQuiets)
return select<Next>([&]() { return *cur != refutations[0] && *cur != refutations[1]; });
return select<Next>([&]() { return *cur != killer; });

return Move::none();

Expand Down
4 changes: 2 additions & 2 deletions src/movepick.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class MovePicker {
const CapturePieceToHistory*,
const PieceToHistory**,
const PawnHistory*,
const Move*);
Move);
MovePicker(const Position&,
Move,
Depth,
Expand All @@ -185,7 +185,7 @@ class MovePicker {
const PieceToHistory** continuationHistory;
const PawnHistory* pawnHistory;
Move ttMove;
ExtMove refutations[2], *cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets;
ExtMove killer, *cur, *endMoves, *endBadCaptures, *beginBadQuiets, *endBadQuiets;
int stage;
int threshold;
Depth depth;
Expand Down
24 changes: 10 additions & 14 deletions src/search.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ 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_refutations(Stack* ss, Move move);
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(
Expand Down Expand Up @@ -608,9 +608,9 @@ Value Search::Worker::search(

assert(0 <= ss->ply && ss->ply < MAX_PLY);

bestMove = Move::none();
(ss + 2)->killers[0] = (ss + 2)->killers[1] = Move::none();
(ss + 2)->cutoffCnt = 0;
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 @@ -934,7 +934,7 @@ Value Search::Worker::search(


MovePicker mp(pos, ttData.move, depth, &thisThread->mainHistory, &thisThread->captureHistory,
contHist, &thisThread->pawnHistory, ss->killers);
contHist, &thisThread->pawnHistory, ss->killer);

value = bestValue;
moveCountPruning = false;
Expand Down Expand Up @@ -1157,7 +1157,7 @@ Value Search::Worker::search(
// Increase reduction for cut nodes (~4 Elo)
if (cutNode)
r += 2 - (ttData.depth >= depth && ss->ttPv)
+ (!ss->ttPv && move != ttData.move && move != ss->killers[0]);
+ (!ss->ttPv && move != ttData.move && move != ss->killer);

// Increase reduction if ttMove is a capture (~3 Elo)
if (ttCapture)
Expand Down Expand Up @@ -1801,7 +1801,7 @@ void update_all_stats(const Position& pos,
// 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)->killers[0]))
|| ((ss - 1)->currentMove == (ss - 1)->killer))
&& !pos.captured_piece())
update_continuation_histories(ss - 1, pos.piece_on(prevSq), prevSq, -quietMoveMalus);

Expand Down Expand Up @@ -1832,14 +1832,10 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
}

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

// Update killers
if (ss->killers[0] != move)
{
ss->killers[1] = ss->killers[0];
ss->killers[0] = move;
}
ss->killer = move;
}

void update_quiet_histories(
Expand All @@ -1858,7 +1854,7 @@ void update_quiet_histories(
void update_quiet_stats(
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {

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

Expand Down
2 changes: 1 addition & 1 deletion src/search.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct Stack {
int ply;
Move currentMove;
Move excludedMove;
Move killers[2];
Move killer;
Value staticEval;
int statScore;
int moveCount;
Expand Down

0 comments on commit 8d1e414

Please sign in to comment.