mirror of
https://github.com/sockspls/badfish
synced 2025-04-30 08:43:09 +00:00
Introduce static history
The idea of this patch can be described as following: we update static history stats based on comparison of the static evaluations of the position before and after the move. If the move increases static evaluation it's assigned positive bonus, if it decreases static evaluation it's assigned negative bonus. These stats are used in movepicker to sort quiet moves. passed STC https://tests.stockfishchess.org/tests/view/5fca4c0842a050a89f02cd66 LLR: 3.00 (-2.94,2.94) {-0.25,1.25} Total: 78152 W: 7409 L: 7171 D: 63572 Ptnml(0-2): 303, 5695, 26873, 5871, 334 passed LTC https://tests.stockfishchess.org/tests/view/5fca6be442a050a89f02cd75 LLR: 2.94 (-2.94,2.94) {0.25,1.25} Total: 40240 W: 1602 L: 1441 D: 37197 Ptnml(0-2): 19, 1306, 17305, 1475, 15 closes https://github.com/official-stockfish/Stockfish/pull/3253 bench 3845156
This commit is contained in:
parent
7364006757
commit
be7a03a957
5 changed files with 21 additions and 4 deletions
|
@ -54,9 +54,9 @@ namespace {
|
||||||
/// ordering is at the current node.
|
/// ordering is at the current node.
|
||||||
|
|
||||||
/// MovePicker constructor for the main search
|
/// MovePicker constructor for the main search
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const LowPlyHistory* lp,
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const ButterflyHistory* sh, const LowPlyHistory* lp,
|
||||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, const Move* killers, int pl)
|
const CapturePieceToHistory* cph, const PieceToHistory** ch, Move cm, const Move* killers, int pl)
|
||||||
: pos(p), mainHistory(mh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
: pos(p), mainHistory(mh), staticHistory(sh), lowPlyHistory(lp), captureHistory(cph), continuationHistory(ch),
|
||||||
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
ttMove(ttm), refutations{{killers[0], 0}, {killers[1], 0}, {cm, 0}}, depth(d), ply(pl) {
|
||||||
|
|
||||||
assert(d > 0);
|
assert(d > 0);
|
||||||
|
@ -66,9 +66,9 @@ MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHist
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MovePicker constructor for quiescence search
|
/// MovePicker constructor for quiescence search
|
||||||
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh,
|
MovePicker::MovePicker(const Position& p, Move ttm, Depth d, const ButterflyHistory* mh, const ButterflyHistory* sh,
|
||||||
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
|
const CapturePieceToHistory* cph, const PieceToHistory** ch, Square rs)
|
||||||
: pos(p), mainHistory(mh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d) {
|
: pos(p), mainHistory(mh), staticHistory(sh), captureHistory(cph), continuationHistory(ch), ttMove(ttm), recaptureSquare(rs), depth(d) {
|
||||||
|
|
||||||
assert(d <= 0);
|
assert(d <= 0);
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ void MovePicker::score() {
|
||||||
|
|
||||||
else if (Type == QUIETS)
|
else if (Type == QUIETS)
|
||||||
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
m.value = (*mainHistory)[pos.side_to_move()][from_to(m)]
|
||||||
|
+ (*staticHistory)[pos.side_to_move()][from_to(m)]
|
||||||
+ 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
+ 2 * (*continuationHistory[0])[pos.moved_piece(m)][to_sq(m)]
|
||||||
+ 2 * (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
+ 2 * (*continuationHistory[1])[pos.moved_piece(m)][to_sq(m)]
|
||||||
+ 2 * (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
+ 2 * (*continuationHistory[3])[pos.moved_piece(m)][to_sq(m)]
|
||||||
|
|
|
@ -123,10 +123,12 @@ public:
|
||||||
MovePicker& operator=(const MovePicker&) = delete;
|
MovePicker& operator=(const MovePicker&) = delete;
|
||||||
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
|
MovePicker(const Position&, Move, Value, const CapturePieceToHistory*);
|
||||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||||
|
const ButterflyHistory*,
|
||||||
const CapturePieceToHistory*,
|
const CapturePieceToHistory*,
|
||||||
const PieceToHistory**,
|
const PieceToHistory**,
|
||||||
Square);
|
Square);
|
||||||
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
MovePicker(const Position&, Move, Depth, const ButterflyHistory*,
|
||||||
|
const ButterflyHistory*,
|
||||||
const LowPlyHistory*,
|
const LowPlyHistory*,
|
||||||
const CapturePieceToHistory*,
|
const CapturePieceToHistory*,
|
||||||
const PieceToHistory**,
|
const PieceToHistory**,
|
||||||
|
@ -143,6 +145,7 @@ private:
|
||||||
|
|
||||||
const Position& pos;
|
const Position& pos;
|
||||||
const ButterflyHistory* mainHistory;
|
const ButterflyHistory* mainHistory;
|
||||||
|
const ButterflyHistory* staticHistory;
|
||||||
const LowPlyHistory* lowPlyHistory;
|
const LowPlyHistory* lowPlyHistory;
|
||||||
const CapturePieceToHistory* captureHistory;
|
const CapturePieceToHistory* captureHistory;
|
||||||
const PieceToHistory** continuationHistory;
|
const PieceToHistory** continuationHistory;
|
||||||
|
|
|
@ -807,6 +807,15 @@ namespace {
|
||||||
tte->save(posKey, VALUE_NONE, ss->ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
|
tte->save(posKey, VALUE_NONE, ss->ttPv, BOUND_NONE, DEPTH_NONE, MOVE_NONE, eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update static history for previous move
|
||||||
|
if (is_ok((ss-1)->currentMove) && !(ss-1)->inCheck && !priorCapture)
|
||||||
|
{
|
||||||
|
int bonus = ss->staticEval > -(ss-1)->staticEval + 2 * Tempo ? -stat_bonus(depth) :
|
||||||
|
ss->staticEval < -(ss-1)->staticEval + 2 * Tempo ? stat_bonus(depth) :
|
||||||
|
0;
|
||||||
|
thisThread->staticHistory[~us][from_to((ss-1)->currentMove)] << bonus;
|
||||||
|
}
|
||||||
|
|
||||||
// Step 7. Razoring (~1 Elo)
|
// Step 7. Razoring (~1 Elo)
|
||||||
if ( !rootNode // The required rootNode PV handling is not available in qsearch
|
if ( !rootNode // The required rootNode PV handling is not available in qsearch
|
||||||
&& depth == 1
|
&& depth == 1
|
||||||
|
@ -964,6 +973,7 @@ moves_loop: // When in check, search starts from here
|
||||||
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
|
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
|
||||||
|
|
||||||
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
||||||
|
&thisThread->staticHistory,
|
||||||
&thisThread->lowPlyHistory,
|
&thisThread->lowPlyHistory,
|
||||||
&captureHistory,
|
&captureHistory,
|
||||||
contHist,
|
contHist,
|
||||||
|
@ -1507,6 +1517,7 @@ moves_loop: // When in check, search starts from here
|
||||||
// queen and checking knight promotions, and other checks(only if depth >= DEPTH_QS_CHECKS)
|
// queen and checking knight promotions, and other checks(only if depth >= DEPTH_QS_CHECKS)
|
||||||
// will be generated.
|
// will be generated.
|
||||||
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
||||||
|
&thisThread->staticHistory,
|
||||||
&thisThread->captureHistory,
|
&thisThread->captureHistory,
|
||||||
contHist,
|
contHist,
|
||||||
to_sq((ss-1)->currentMove));
|
to_sq((ss-1)->currentMove));
|
||||||
|
|
|
@ -57,6 +57,7 @@ void Thread::clear() {
|
||||||
|
|
||||||
counterMoves.fill(MOVE_NONE);
|
counterMoves.fill(MOVE_NONE);
|
||||||
mainHistory.fill(0);
|
mainHistory.fill(0);
|
||||||
|
staticHistory.fill(0);
|
||||||
lowPlyHistory.fill(0);
|
lowPlyHistory.fill(0);
|
||||||
captureHistory.fill(0);
|
captureHistory.fill(0);
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ public:
|
||||||
Depth rootDepth, completedDepth;
|
Depth rootDepth, completedDepth;
|
||||||
CounterMoveHistory counterMoves;
|
CounterMoveHistory counterMoves;
|
||||||
ButterflyHistory mainHistory;
|
ButterflyHistory mainHistory;
|
||||||
|
ButterflyHistory staticHistory;
|
||||||
LowPlyHistory lowPlyHistory;
|
LowPlyHistory lowPlyHistory;
|
||||||
CapturePieceToHistory captureHistory;
|
CapturePieceToHistory captureHistory;
|
||||||
ContinuationHistory continuationHistory[2][2];
|
ContinuationHistory continuationHistory[2][2];
|
||||||
|
|
Loading…
Add table
Reference in a new issue