1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Addition of new scaling comments

This patch is intended to prevent patches like 9b90cd8 and the
subsequent reversion e3c9ed7 from happening again. Scaling behaviour of
the reduction adjustments in the non-linear scaling
section have been proven to >8 sigma:

STC: https://tests.stockfishchess.org/tests/view/6647b19f6dcff0d1d6b05d52
Elo: 4.28 ± 0.8 (95%) LOS: 100.0%
Total: 200000 W: 52555 L: 50094 D: 97351
Ptnml(0-2): 573, 22628, 51248, 24867, 684
nElo: 8.35 ± 1.5 (95%) PairsRatio: 1.10

VLTC: https://tests.stockfishchess.org/tests/view/6647b1b06dcff0d1d6b05d54
Elo: -1.48 ± 1.0 (95%) LOS: 0.2%
Total: 100000 W: 25009 L: 25436 D: 49555
Ptnml(0-2): 11, 10716, 28971, 10293, 9
nElo: -3.23 ± 2.2 (95%) PairsRatio: 0.96

The else if condition is moved to the non scaling section based on:
https://tests.stockfishchess.org/tests/view/664567a193ce6da3e93b3232 (It
has no proven scaling)

General comment improvements and removal of a redundant margin condition
have also been included.

closes https://github.com/official-stockfish/Stockfish/pull/5266

No functional change
This commit is contained in:
Viren6 2024-05-19 02:58:01 +01:00 committed by Disservin
parent ed79745bb9
commit 6db47ed71a

View file

@ -840,7 +840,8 @@ Value Search::Worker::search(
if (depth <= 0)
return qsearch < PvNode ? PV : NonPV > (pos, ss, alpha, beta);
// For cutNodes without a ttMove, we decrease depth by 2 if depth is high enough.
// For cutNodes, if depth is high enough, decrease depth by 2 if there is no ttMove, or
// by 1 if there is a ttMove with an upper bound.
if (cutNode && depth >= 8 && (!ttMove || tte->bound() == BOUND_UPPER))
depth -= 1 + !ttMove;
@ -1042,11 +1043,14 @@ moves_loop: // When in check, search starts here
// then that move is singular and should be extended. To verify this we do
// a reduced search on the position excluding the ttMove and if the result
// is lower than ttValue minus a margin, then we will extend the ttMove.
// Recursive singular search is avoided.
// Note: the depth margin and singularBeta margin are known for having non-linear
// scaling. Their values are optimized to time controls of 180+1.8 and longer
// so changing them requires tests at these types of time controls.
// Recursive singular search is avoided.
// Generally, higher singularBeta (i.e closer to ttValue) and lower extension
// margins scale well.
if (!rootNode && move == ttMove && !excludedMove
&& depth >= 4 - (thisThread->completedDepth > 35) + ss->ttPv
&& std::abs(ttValue) < VALUE_TB_WIN_IN_MAX_PLY && (tte->bound() & BOUND_LOWER)
@ -1063,9 +1067,8 @@ moves_loop: // When in check, search starts here
if (value < singularBeta)
{
int doubleMargin = 298 * PvNode - 209 * !ttCapture;
int tripleMargin =
117 + 252 * PvNode - 270 * !ttCapture + 111 * (ss->ttPv || !ttCapture);
int quadMargin = 471 + 343 * PvNode - 281 * !ttCapture + 217 * ss->ttPv;
int tripleMargin = 117 + 252 * PvNode - 270 * !ttCapture + 111 * ss->ttPv;
int quadMargin = 471 + 343 * PvNode - 281 * !ttCapture + 217 * ss->ttPv;
extension = 1 + (value < singularBeta - doubleMargin)
+ (value < singularBeta - tripleMargin)
@ -1127,25 +1130,30 @@ moves_loop: // When in check, search starts here
thisThread->nodes.fetch_add(1, std::memory_order_relaxed);
pos.do_move(move, st, givesCheck);
// These reduction adjustments have proven non-linear scaling.
// They are optimized to time controls of 180 + 1.8 and longer so
// changing them or adding conditions that are similar
// requires tests at these types of time controls.
// Decrease reduction if position is or has been on the PV (~7 Elo)
if (ss->ttPv)
r -= 1 + (ttValue > alpha) + (tte->depth() >= depth);
else if (cutNode && move != ttMove && move != ss->killers[0])
r++;
// Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC)
if (PvNode)
r--;
// These reduction adjustments have no proven non-linear scaling.
// Increase reduction for cut nodes (~4 Elo)
if (cutNode)
r += 2 - (tte->depth() >= depth && ss->ttPv);
r += 2 - (tte->depth() >= depth && ss->ttPv)
+ (!ss->ttPv && move != ttMove && move != ss->killers[0]);
// Increase reduction if ttMove is a capture (~3 Elo)
if (ttCapture)
r++;
// Decrease reduction for PvNodes (~0 Elo on STC, ~2 Elo on LTC)
if (PvNode)
r--;
// Increase reduction if next ply has a lot of fail high (~5 Elo)
if ((ss + 1)->cutoffCnt > 3)
r++;