mirror of
https://github.com/HChaZZY/Stockfish.git
synced 2025-12-22 01:56:58 +08:00
Improve move order near the root
Current move histories are known to work well near the leaves, whilst at higher depths they aren't very helpful. To address this problem this patch introduces a table dedicated for what's happening at plies 0-3. It's structured like mainHistory with ply index instead of color. It get cleared with each new search and is filled during iterative deepening at higher depths when recording successful quiet moves near the root or traversing nodes which were in the principal variation (ttPv). Medium TC (20+0.2): https://tests.stockfishchess.org/tests/view/5e4d358790a0a02810d096dc LLR: 2.94 (-2.94,2.94) {-0.50,1.50} Total: 100910 W: 16682 L: 16376 D: 67852 Ptnml(0-2): 1177, 10983, 25883, 11181, 1231 LTC: https://tests.stockfishchess.org/tests/view/5e4e2cb790a0a02810d09714 LLR: 2.95 (-2.94,2.94) {0.25,1.75} Total: 80444 W: 10495 L: 10095 D: 59854 Ptnml(0-2): 551, 7479, 23803, 7797, 592 closes https://github.com/official-stockfish/Stockfish/pull/2557 Bench: 4705960
This commit is contained in:
committed by
Joost VandeVondele
parent
ab930f8d3f
commit
b8c00efa27
@@ -156,7 +156,7 @@ namespace {
|
||||
Value value_from_tt(Value v, int ply, int r50c);
|
||||
void update_pv(Move* pv, Move move, Move* childPv);
|
||||
void update_continuation_histories(Stack* ss, Piece pc, Square to, int bonus);
|
||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus);
|
||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth);
|
||||
void update_all_stats(const Position& pos, Stack* ss, Move bestMove, Value bestValue, Value beta, Square prevSq,
|
||||
Move* quietsSearched, int quietCount, Move* capturesSearched, int captureCount, Depth depth);
|
||||
|
||||
@@ -695,6 +695,10 @@ namespace {
|
||||
ttMove = rootNode ? thisThread->rootMoves[thisThread->pvIdx].pv[0]
|
||||
: ttHit ? tte->move() : MOVE_NONE;
|
||||
ttPv = PvNode || (ttHit && tte->is_pv());
|
||||
|
||||
if (ttPv && depth > 12 && ss->ply - 1 < MAX_LPH && !pos.captured_piece() && is_ok((ss-1)->currentMove))
|
||||
thisThread->lowPlyHistory[ss->ply - 1][from_to((ss-1)->currentMove)] << stat_bonus(depth - 5);
|
||||
|
||||
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
|
||||
thisThread->ttHitAverage = (ttHitAverageWindow - 1) * thisThread->ttHitAverage / ttHitAverageWindow
|
||||
+ ttHitAverageResolution * ttHit;
|
||||
@@ -713,7 +717,7 @@ namespace {
|
||||
if (ttValue >= beta)
|
||||
{
|
||||
if (!pos.capture_or_promotion(ttMove))
|
||||
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth));
|
||||
update_quiet_stats(pos, ss, ttMove, stat_bonus(depth), depth);
|
||||
|
||||
// Extra penalty for early quiet moves of the previous ply
|
||||
if ((ss-1)->moveCount <= 2 && !priorCapture)
|
||||
@@ -948,10 +952,12 @@ moves_loop: // When in check, search starts from here
|
||||
Move countermove = thisThread->counterMoves[pos.piece_on(prevSq)][prevSq];
|
||||
|
||||
MovePicker mp(pos, ttMove, depth, &thisThread->mainHistory,
|
||||
&thisThread->lowPlyHistory,
|
||||
&thisThread->captureHistory,
|
||||
contHist,
|
||||
countermove,
|
||||
ss->killers);
|
||||
ss->killers,
|
||||
depth > 12 && ttPv ? ss->ply : MAX_PLY);
|
||||
|
||||
value = bestValue;
|
||||
singularLMR = moveCountPruning = false;
|
||||
@@ -1633,7 +1639,7 @@ moves_loop: // When in check, search starts from here
|
||||
|
||||
if (!pos.capture_or_promotion(bestMove))
|
||||
{
|
||||
update_quiet_stats(pos, ss, bestMove, bonus2);
|
||||
update_quiet_stats(pos, ss, bestMove, bonus2, depth);
|
||||
|
||||
// Decrease all the non-best quiet moves
|
||||
for (int i = 0; i < quietCount; ++i)
|
||||
@@ -1673,7 +1679,7 @@ moves_loop: // When in check, search starts from here
|
||||
|
||||
// update_quiet_stats() updates move sorting heuristics
|
||||
|
||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus) {
|
||||
void update_quiet_stats(const Position& pos, Stack* ss, Move move, int bonus, int depth) {
|
||||
|
||||
if (ss->killers[0] != move)
|
||||
{
|
||||
@@ -1694,6 +1700,9 @@ moves_loop: // When in check, search starts from here
|
||||
Square prevSq = to_sq((ss-1)->currentMove);
|
||||
thisThread->counterMoves[pos.piece_on(prevSq)][prevSq] = move;
|
||||
}
|
||||
|
||||
if (depth > 12 && ss->ply < MAX_LPH)
|
||||
thisThread->lowPlyHistory[ss->ply][from_to(move)] << stat_bonus(depth - 7);
|
||||
}
|
||||
|
||||
// When playing with strength handicap, choose best move among a set of RootMoves
|
||||
|
||||
Reference in New Issue
Block a user