Skip to content

Commit 6da1590

Browse files
cj5716vondele
authored andcommitted
Some history fixes and tidy-up
This adds the functions `update_refutations` and `update_quiet_histories` to better distinguish the two. `update_quiet_stats` now just calls both of these functions. The functional side of this patch is two-fold: 1. Stop refutations being updated when we carry out multicut 2. Update pawn history every time we update other quiet histories Yellow STC: LLR: -2.95 (-2.94,2.94) <0.00,2.00> Total: 238976 W: 61506 L: 61415 D: 116055 Ptnml(0-2): 846, 28628, 60456, 28705, 853 https://tests.stockfishchess.org/tests/view/66321b5ed01fb9ac9bcdca83 However, it passed in <-1.75, 0.25> bounds: $ python3 sprt.py --wins 61506 --losses 61415 --draws 116055 --elo0 -1.75 --elo1 0.25 ELO: 0.132 +- 0.998 [-0.865, 1.13] LLR: 4.15 [-1.75, 0.25] (-2.94, 2.94) H1 Accepted Passed LTC: LLR: 2.94 (-2.94,2.94) <-1.75,0.25> Total: 399126 W: 100730 L: 100896 D: 197500 Ptnml(0-2): 116, 44328, 110843, 44158, 118 https://tests.stockfishchess.org/tests/view/66357b0473559a8aa857ba6f closes #5215 Bench 2370967
1 parent d712ed3 commit 6da1590

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

src/search.cpp

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,11 @@ Value value_to_tt(Value v, int ply);
114114
Value value_from_tt(Value v, int ply, int r50c);
115115
void update_pv(Move* pv, Move move, const Move* childPv);
116116
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
117-
void update_quiet_stats(
117+
void update_refutations(const Position& pos, Stack* ss, Search::Worker& workerThread, Move move);
118+
void update_quiet_histories(
118119
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
120+
void update_quiet_stats(
121+
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus);
119122
void update_all_stats(const Position& pos,
120123
Stack* ss,
121124
Search::Worker& workerThread,
@@ -1068,7 +1071,7 @@ Value Search::Worker::search(
10681071
else if (singularBeta >= beta)
10691072
{
10701073
if (!ttCapture)
1071-
update_quiet_stats(pos, ss, *this, ttMove, -stat_malus(depth));
1074+
update_quiet_histories(pos, ss, *this, ttMove, -stat_malus(depth));
10721075

10731076
return singularBeta;
10741077
}
@@ -1724,7 +1727,6 @@ void update_all_stats(const Position& pos,
17241727
int captureCount,
17251728
Depth depth) {
17261729

1727-
Color us = pos.side_to_move();
17281730
CapturePieceToHistory& captureHistory = workerThread.captureHistory;
17291731
Piece moved_piece = pos.moved_piece(bestMove);
17301732
PieceType captured;
@@ -1737,23 +1739,11 @@ void update_all_stats(const Position& pos,
17371739
int bestMoveBonus = bestValue > beta + 185 ? quietMoveBonus // larger bonus
17381740
: stat_bonus(depth); // smaller bonus
17391741

1740-
// Increase stats for the best move in case it was a quiet move
17411742
update_quiet_stats(pos, ss, workerThread, bestMove, bestMoveBonus);
17421743

1743-
int pIndex = pawn_structure_index(pos);
1744-
workerThread.pawnHistory[pIndex][moved_piece][bestMove.to_sq()] << quietMoveBonus;
1745-
17461744
// Decrease stats for all non-best quiet moves
17471745
for (int i = 0; i < quietCount; ++i)
1748-
{
1749-
workerThread
1750-
.pawnHistory[pIndex][pos.moved_piece(quietsSearched[i])][quietsSearched[i].to_sq()]
1751-
<< -quietMoveMalus;
1752-
1753-
workerThread.mainHistory[us][quietsSearched[i].from_to()] << -quietMoveMalus;
1754-
update_continuation_histories(ss, pos.moved_piece(quietsSearched[i]),
1755-
quietsSearched[i].to_sq(), -quietMoveMalus);
1756-
}
1746+
update_quiet_histories(pos, ss, workerThread, quietsSearched[i], -quietMoveMalus);
17571747
}
17581748
else
17591749
{
@@ -1794,10 +1784,8 @@ void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus) {
17941784
}
17951785
}
17961786

1797-
17981787
// Updates move sorting heuristics
1799-
void update_quiet_stats(
1800-
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {
1788+
void update_refutations(const Position& pos, Stack* ss, Search::Worker& workerThread, Move move) {
18011789

18021790
// Update killers
18031791
if (ss->killers[0] != move)
@@ -1806,17 +1794,34 @@ void update_quiet_stats(
18061794
ss->killers[0] = move;
18071795
}
18081796

1809-
Color us = pos.side_to_move();
1810-
workerThread.mainHistory[us][move.from_to()] << bonus;
1811-
update_continuation_histories(ss, pos.moved_piece(move), move.to_sq(), bonus);
1812-
18131797
// Update countermove history
18141798
if (((ss - 1)->currentMove).is_ok())
18151799
{
18161800
Square prevSq = ((ss - 1)->currentMove).to_sq();
18171801
workerThread.counterMoves[pos.piece_on(prevSq)][prevSq] = move;
18181802
}
18191803
}
1804+
1805+
void update_quiet_histories(
1806+
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {
1807+
1808+
Color us = pos.side_to_move();
1809+
workerThread.mainHistory[us][move.from_to()] << bonus;
1810+
1811+
update_continuation_histories(ss, pos.moved_piece(move), move.to_sq(), bonus);
1812+
1813+
int pIndex = pawn_structure_index(pos);
1814+
workerThread.pawnHistory[pIndex][pos.moved_piece(move)][move.to_sq()] << bonus;
1815+
}
1816+
1817+
// Updates move sorting heuristics
1818+
void update_quiet_stats(
1819+
const Position& pos, Stack* ss, Search::Worker& workerThread, Move move, int bonus) {
1820+
1821+
update_refutations(pos, ss, workerThread, move);
1822+
update_quiet_histories(pos, ss, workerThread, move, bonus);
1823+
}
1824+
18201825
}
18211826

18221827
// When playing with strength handicap, choose the best move among a set of RootMoves

0 commit comments

Comments
 (0)