Skip to content

Commit 9a063fc

Browse files
Vizvezdenecvondele
authored andcommitted
Adjust penalty on refuted early quiet moves
This patch changes how previous early moves are penalized in case search finds a best move. Here, the first quiet move that was not a transposition table move is penalized. passed STC https://tests.stockfishchess.org/tests/view/5f51d839ba100690c5cc5f69 LLR: 2.94 (-2.94,2.94) {-0.25,1.25} Total: 10088 W: 1150 L: 997 D: 7941 Ptnml(0-2): 41, 772, 3278, 899, 54 passed LTC https://tests.stockfishchess.org/tests/view/5f51e435ba100690c5cc5f76 LLR: 2.93 (-2.94,2.94) {0.25,1.25} Total: 30808 W: 1564 L: 1405 D: 27839 Ptnml(0-2): 19, 1245, 12717, 1404, 19 closes #3106 bench 3983758
1 parent 9cc482c commit 9a063fc

File tree

2 files changed

+22
-21
lines changed

2 files changed

+22
-21
lines changed

src/search.cpp

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,7 @@ namespace {
597597
Move ttMove, move, excludedMove, bestMove;
598598
Depth extension, newDepth;
599599
Value bestValue, value, ttValue, eval, maxValue, probCutBeta;
600-
bool ttHit, formerPv, givesCheck, improving, didLMR, priorCapture;
600+
bool formerPv, givesCheck, improving, didLMR, priorCapture;
601601
bool captureOrPromotion, doFullDepthSearch, moveCountPruning,
602602
ttCapture, singularQuietLMR;
603603
Piece movedPiece;
@@ -664,12 +664,12 @@ namespace {
664664
// position key in case of an excluded move.
665665
excludedMove = ss->excludedMove;
666666
posKey = excludedMove == MOVE_NONE ? pos.key() : pos.key() ^ make_key(excludedMove);
667-
tte = TT.probe(posKey, ttHit);
668-
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply, pos.rule50_count()) : VALUE_NONE;
667+
tte = TT.probe(posKey, ss->ttHit);
668+
ttValue = ss->ttHit ? value_from_tt(tte->value(), ss->ply, pos.rule50_count()) : VALUE_NONE;
669669
ttMove = rootNode ? thisThread->rootMoves[thisThread->pvIdx].pv[0]
670-
: ttHit ? tte->move() : MOVE_NONE;
670+
: ss->ttHit ? tte->move() : MOVE_NONE;
671671
if (!excludedMove)
672-
ss->ttPv = PvNode || (ttHit && tte->is_pv());
672+
ss->ttPv = PvNode || (ss->ttHit && tte->is_pv());
673673
formerPv = ss->ttPv && !PvNode;
674674

675675
if ( ss->ttPv
@@ -681,11 +681,11 @@ namespace {
681681

682682
// thisThread->ttHitAverage can be used to approximate the running average of ttHit
683683
thisThread->ttHitAverage = (TtHitAverageWindow - 1) * thisThread->ttHitAverage / TtHitAverageWindow
684-
+ TtHitAverageResolution * ttHit;
684+
+ TtHitAverageResolution * ss->ttHit;
685685

686686
// At non-PV nodes we check for an early TT cutoff
687687
if ( !PvNode
688-
&& ttHit
688+
&& ss->ttHit
689689
&& tte->depth() >= depth
690690
&& ttValue != VALUE_NONE // Possible in case of TT access race
691691
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
@@ -778,7 +778,7 @@ namespace {
778778
improving = false;
779779
goto moves_loop;
780780
}
781-
else if (ttHit)
781+
else if (ss->ttHit)
782782
{
783783
// Never assume anything about values stored in TT
784784
ss->staticEval = eval = tte->eval();
@@ -882,14 +882,14 @@ namespace {
882882
// there and in further interactions with transposition table cutoff depth is set to depth - 3
883883
// because probCut search has depth set to depth - 4 but we also do a move before it
884884
// so effective depth is equal to depth - 3
885-
&& !( ttHit
885+
&& !( ss->ttHit
886886
&& tte->depth() >= depth - 3
887887
&& ttValue != VALUE_NONE
888888
&& ttValue < probCutBeta))
889889
{
890890
// if ttMove is a capture and value from transposition table is good enough produce probCut
891891
// cutoff without digging into actual probCut search
892-
if ( ttHit
892+
if ( ss->ttHit
893893
&& tte->depth() >= depth - 3
894894
&& ttValue != VALUE_NONE
895895
&& ttValue >= probCutBeta
@@ -933,7 +933,7 @@ namespace {
933933
if (value >= probCutBeta)
934934
{
935935
// if transposition table doesn't have equal or more deep info write probCut data into it
936-
if ( !(ttHit
936+
if ( !(ss->ttHit
937937
&& tte->depth() >= depth - 3
938938
&& ttValue != VALUE_NONE))
939939
tte->save(posKey, value_to_tt(value, ss->ply), ttPv,
@@ -1423,7 +1423,7 @@ namespace {
14231423
Move ttMove, move, bestMove;
14241424
Depth ttDepth;
14251425
Value bestValue, value, ttValue, futilityValue, futilityBase, oldAlpha;
1426-
bool ttHit, pvHit, givesCheck, captureOrPromotion;
1426+
bool pvHit, givesCheck, captureOrPromotion;
14271427
int moveCount;
14281428

14291429
if (PvNode)
@@ -1453,13 +1453,13 @@ namespace {
14531453
: DEPTH_QS_NO_CHECKS;
14541454
// Transposition table lookup
14551455
posKey = pos.key();
1456-
tte = TT.probe(posKey, ttHit);
1457-
ttValue = ttHit ? value_from_tt(tte->value(), ss->ply, pos.rule50_count()) : VALUE_NONE;
1458-
ttMove = ttHit ? tte->move() : MOVE_NONE;
1459-
pvHit = ttHit && tte->is_pv();
1456+
tte = TT.probe(posKey, ss->ttHit);
1457+
ttValue = ss->ttHit ? value_from_tt(tte->value(), ss->ply, pos.rule50_count()) : VALUE_NONE;
1458+
ttMove = ss->ttHit ? tte->move() : MOVE_NONE;
1459+
pvHit = ss->ttHit && tte->is_pv();
14601460

14611461
if ( !PvNode
1462-
&& ttHit
1462+
&& ss->ttHit
14631463
&& tte->depth() >= ttDepth
14641464
&& ttValue != VALUE_NONE // Only in case of TT access race
14651465
&& (ttValue >= beta ? (tte->bound() & BOUND_LOWER)
@@ -1474,7 +1474,7 @@ namespace {
14741474
}
14751475
else
14761476
{
1477-
if (ttHit)
1477+
if (ss->ttHit)
14781478
{
14791479
// Never assume anything about values stored in TT
14801480
if ((ss->staticEval = bestValue = tte->eval()) == VALUE_NONE)
@@ -1493,7 +1493,7 @@ namespace {
14931493
// Stand pat. Return immediately if static value is at least beta
14941494
if (bestValue >= beta)
14951495
{
1496-
if (!ttHit)
1496+
if (!ss->ttHit)
14971497
tte->save(posKey, value_to_tt(bestValue, ss->ply), false, BOUND_LOWER,
14981498
DEPTH_NONE, MOVE_NONE, ss->staticEval);
14991499

@@ -1711,8 +1711,8 @@ namespace {
17111711
else
17121712
captureHistory[moved_piece][to_sq(bestMove)][captured] << bonus1;
17131713

1714-
// Extra penalty for a quiet TT or main killer move in previous ply when it gets refuted
1715-
if ( ((ss-1)->moveCount == 1 || ((ss-1)->currentMove == (ss-1)->killers[0]))
1714+
// Extra penalty for a quiet early move that was not a TT move or main killer move in previous ply when it gets refuted
1715+
if ( ((ss-1)->moveCount == 1 + (ss-1)->ttHit || ((ss-1)->currentMove == (ss-1)->killers[0]))
17161716
&& !pos.captured_piece())
17171717
update_continuation_histories(ss-1, pos.piece_on(prevSq), prevSq, -bonus1);
17181718

src/search.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct Stack {
4949
int moveCount;
5050
bool inCheck;
5151
bool ttPv;
52+
bool ttHit;
5253
};
5354

5455

0 commit comments

Comments
 (0)