]> git.sesse.net Git - stockfish/log
stockfish
14 months agoFix duplicated moves generation in movepicker
Michael Chaly [Fri, 24 Feb 2023 09:09:45 +0000 (12:09 +0300)]
Fix duplicated moves generation in movepicker

in a some of cases movepicker returned some moves more than once which lead
to them being searched more than once. This bug was possible because of how
we use queen promotions - they are generated as a captures but are not
included in position function which checks if move is a capture. Thus if
any refutation (killer or countermove) was a queen promotion it was
searched twice - once as a capture and one as a refutation.

This patch affects various things, namely stats assignments for queen promotions
and other moves if best move is queen promotion,
also some heuristics in search and qsearch.

With this patch every queen promotion is now considered a capture.

After this patch number of found duplicated moves is 0 during normal 13 depth bench run.

Passed STC:
https://tests.stockfishchess.org/tests/view/63f77e01e74a12625bcd87d7
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 80920 W: 21455 L: 21289 D: 38176
Ptnml(0-2): 198, 8839, 22241, 8963, 219

Passed LTC:
https://tests.stockfishchess.org/tests/view/63f7e020e74a12625bcd9a76
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 89712 W: 23674 L: 23533 D: 42505
Ptnml(0-2): 24, 8737, 27202, 8860, 33

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

bench 4681731

14 months agoUpdate default net to nn-52471d67216a.nnue
Linmiao Xu [Fri, 24 Feb 2023 14:16:55 +0000 (09:16 -0500)]
Update default net to nn-52471d67216a.nnue

Created by retraining the master net with modifications to the previous best dataset:

* Improving T80 oct+nov 2022 endgame lambda accuracy by rescoring with 12-16tb of syzygy 7p tablebases
* Filtering T78 jun+jul+aug 2022 with d6pv2 search to remove positions with bestmove captures or one good move
* Adding T80 sep 2022 data, rescored with 16tb of 7p tablebases, unfiltered

Trained with max-epoch 900, end-lambda 0.7, and early-fen-skipping 28.

```
python3 easy_train.py \
  --experiment-name leela96-dfrc99-T80octnovT79aprmayT78junjulaugT60novdec-filt-v2-T78sep12tb7p-T77decT80sep16tb7p-lambda7-sk28 \
  --training-dataset /data/leela96-dfrc99-T80octnovT79aprmayT78junjulaugT60novdec-filt-v2-T78sep12tb7p-T77decT80sep16tb7p.binpack \
  --nnue-pytorch-branch linrock/nnue-pytorch/easy-train-early-fen-skipping \
  --early-fen-skipping 28 \
  --start-from-engine-test-net True \
  --gpus "0," \
  --max_epoch 900 \
  --start-lambda 1.0 \
  --end-lambda 0.7 \
  --gamma 0.995 \
  --lr 4.375e-4 \
  --tui False \
  --seed $RANDOM
```

Training data was rescored and d6pv2 filtered in the same way as recent best datasets.
For preparing the merged training dataset:

```
python3 interleave_binpacks.py \
  leela96-eval-filt-v2.binpack \
  dfrc99-eval-filt-v2.binpack \
  test80-oct2022-16tb7p-eval-filt-v2-d6.binpack \
  test80-nov2022-12tb7p-eval-filt-v2-d6.binpack \
  T79-apr2022-12tb7p-eval-filt-v2.binpack \
  T79-may2022-12tb7p-eval-filt-v2.binpack \
  test78-junjulaug2022-16tb7p-eval-filt-v2-d6.binpack \
  T60-nov2021-12tb7p-eval-filt-v2.binpack \
  T60-dec2021-12tb7p-eval-filt-v2.binpack \
  T78-sep2022-12tb7p.binpack \
  test77-dec2021-16gb7p.binpack \
  test80-sep2022-16tb7p.binpack \
  /data/leela96-dfrc99-T80octnovT79aprmayT78junjulaugT60novdec-filt-v2-T78sep12tb7p-T77decT80sep16tb7p.binpack
```

Links for downloading the training data components can be found at:
https://robotmoon.com/nnue-training-data/

Local elo at 25k nodes per move:
nn-epoch839.nnue : 0.6 +/- 1.4

Passed STC:
https://tests.stockfishchess.org/tests/view/63f9ab4be74a12625bcdf02e
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 84656 W: 22681 L: 22302 D: 39673
Ptnml(0-2): 271, 9343, 22734, 9696, 284

Passed LTC:
https://tests.stockfishchess.org/tests/view/63fa3833e74a12625bce0c0e
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 184664 W: 49933 L: 49344 D: 85387
Ptnml(0-2): 111, 17977, 55561, 18578, 105

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

bench: 4814343

14 months agoLate counter bonus: boost underestimated moves
Dubslow [Wed, 22 Feb 2023 11:45:43 +0000 (05:45 -0600)]
Late counter bonus: boost underestimated moves

The idea here is very intuitive: since we've just proven that the move is good, then if it previously had poor stats, boost those stats more than otherwise.

Passed STC: https://tests.stockfishchess.org/tests/view/63fb504ce74a12625bce4154
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 21128 W: 5763 L: 5481 D: 9884
Ptnml(0-2): 52, 2212, 5759, 2484, 57

Passed LTC: https://tests.stockfishchess.org/tests/view/63fb7825e74a12625bce491b
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 91904 W: 24764 L: 24359 D: 42781
Ptnml(0-2): 45, 8735, 27984, 9146, 42

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

bench 4318808

14 months agoUnify type alias declarations
Sebastian Buchwald [Sun, 26 Feb 2023 18:42:31 +0000 (19:42 +0100)]
Unify type alias declarations

The commit unifies the declaration of type aliases by replacing all
typedefs with corresponding using statements.

closing https://github.com/official-stockfish/Stockfish/pull/4412

No functional change

14 months agoNNUE accumulator update in probcut.
Stefan Geschwentner [Sun, 26 Feb 2023 08:56:54 +0000 (09:56 +0100)]
NNUE accumulator update in probcut.

Call the recently added hint function for NNUE accumulator update after a failed probcut search.
In this case we already searched at least some captures and tt move which, however, is not sufficient for a cutoff.
So it seems we have a greater chance that the full search will also have no cutoff and hence all moves have to be searched.

STC: https://tests.stockfishchess.org/tests/view/63fa74a4e74a12625bce1823
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 70096 W: 18770 L: 18423 D: 32903
Ptnml(0-2): 191, 7342, 19654, 7651, 210

To be sure that we have no heavy interaction retest on top of #4410.

Rebased STC: https://tests.stockfishchess.org/tests/view/63fb2f62e74a12625bce3b03
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 137688 W: 36790 L: 36349 D: 64549
Ptnml(0-2): 397, 14373, 38919, 14702, 453

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

No functional change

14 months agoUse common_parent_position hint also at PVNodes TT hits.
pb00067 [Sun, 26 Feb 2023 08:59:35 +0000 (09:59 +0100)]
Use common_parent_position hint also at PVNodes TT hits.

Credits to Stefan Geschwentner (locutus2) showing that the hint
is useful on PvNodes. In contrast to his test,
this version avoids to use the hint when in check.
I believe checking positions aren't good candidates for the hint
because:
- evasion moves are rather few, so a checking pos. has much less childs
than a normal position
- if the king has to move the NNUE eval can't use incremental updates,
  so the child nodes have to do a full refresh anyway.

Passed STC:
https://tests.stockfishchess.org/tests/view/63f9c5b1e74a12625bcdf585
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 124472 W: 33268 L: 32846 D: 58358
Ptnml(0-2): 350, 12986, 35170, 13352, 378

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

no functional change

14 months agoSimplify condition in step 15
Alfredo Menezes [Mon, 27 Feb 2023 03:39:26 +0000 (00:39 -0300)]
Simplify condition in step 15

Remove 'ttValue <= alpha' check for negative extension in singular search.
Also apply some small code style changes.

STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 127888 W: 33766 L: 33651 D: 60471
Ptnml(0-2): 303, 14082, 35089, 14137, 333
https://tests.stockfishchess.org/tests/view/63f79528e74a12625bcd8c05

LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 89048 W: 23924 L: 23782 D: 41342
Ptnml(0-2): 27, 8635, 27065, 8763, 34
https://tests.stockfishchess.org/tests/view/63f82177e74a12625bcda6f4

LTC (retest):
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 196360 W: 52514 L: 52475 D: 91371
Ptnml(0-2): 103, 19066, 59780, 19151, 80
https://tests.stockfishchess.org/tests/view/63f934bfe74a12625bcdd929

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

Bench: 5310866

14 months agoSearch tuning at very long time control
Michael Chaly [Fri, 24 Feb 2023 15:25:24 +0000 (18:25 +0300)]
Search tuning at very long time control

This patch is a result of tuning session of approximately 100k games at 120+1.2.
Biggest changes are in extensions, stat bonus and depth reduction for nodes without a tt move.

Failed STC:
https://tests.stockfishchess.org/tests/view/63f72c72e74a12625bcd7938
LLR: -2.94 (-2.94,2.94) <0.00,2.00>
Total: 13872 W: 3535 L: 3769 D: 6568
Ptnml(0-2): 56, 1621, 3800, 1419, 40

Close to neutral at LTC:
https://tests.stockfishchess.org/tests/view/63f738f5e74a12625bcd7b8a
Elo: 0.80 +-1.2 (95%) LOS: 90.0%
Total: 60000 W: 16213 L: 16074 D: 27713
Ptnml(0-2): 24, 5718, 18379, 5853, 26
nElo: 1.82 +-2.8 (95%) PairsRatio: 1.02

Passed 180+1.8 VLTC:
https://tests.stockfishchess.org/tests/view/63f868f3e74a12625bcdb33e
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 15864 W: 4449 L: 4202 D: 7213
Ptnml(0-2): 1, 1301, 5083, 1544, 3

Passed 60+0.6 8 threads SMP VLTC:
https://tests.stockfishchess.org/tests/view/63f8a5d6e74a12625bcdbdb3
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 6288 W: 1821 L: 1604 D: 2863
Ptnml(0-2): 0, 402, 2123, 619, 0

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

bench 4705194

14 months agoFix typo in method name
Sebastian Buchwald [Thu, 23 Feb 2023 18:01:51 +0000 (19:01 +0100)]
Fix typo in method name

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

No functional change

14 months agoReintroduce nnue pawn scaling with lower lazy thresholds
Linmiao Xu [Tue, 21 Feb 2023 16:17:59 +0000 (11:17 -0500)]
Reintroduce nnue pawn scaling with lower lazy thresholds

Params found with the nevergrad TBPSA optimizer via nevergrad4sf modified to:

* use SPRT LLR with fishtest STC elo gainer bounds [0, 2] as the objective function
* increase the game batch size after each new optimal point is found

The params were the optimal point after TBPSA iteration 7 and 160 nevergrad evaluations with:

* initial batch size of 96 games per evaluation
* batch size increase of 64 games after each iteration
* a budget of 512 evaluations
* TC: fixed 1.5 million nodes per move, no time limit

nevergrad4sf enables optimizing stockfish params with TBPSA:
https://github.com/vondele/nevergrad4sf

Using pentanomial game results with smaller game batch sizes was inspired by:

Use of SPRT LLR calculated from pentanomial game results as the objective function was an experiment at maximizing the information from game batches to reduce the computational cost for TBPSA to converge on good parameters.

For the exact code used to find the params:
https://github.com/linrock/tuning-fork

Passed STC:
https://tests.stockfishchess.org/tests/view/63f4ef5ee74a12625bcd114a
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 66552 W: 17736 L: 17390 D: 31426
Ptnml(0-2): 164, 7229, 18166, 7531, 186

Passed LTC:
https://tests.stockfishchess.org/tests/view/63f56028e74a12625bcd2550
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 71264 W: 19150 L: 18787 D: 33327
Ptnml(0-2): 23, 6728, 21771, 7083, 27

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

bench 3687580

14 months agoIntroduce a function to compute NNUE accumulator
Joost VandeVondele [Mon, 20 Feb 2023 19:02:55 +0000 (20:02 +0100)]
Introduce a function to compute NNUE accumulator

This patch introduces `hint_common_parent_position()` to signal that potentially several child nodes will require an NNUE eval. By populating explicitly the accumulator, these subsequent evaluations can be performed more efficiently.

This was based on the observation that calculating the evaluation in an excluded move position yielded a significant Elo gain, even though the evaluation itself was already available (work by pb00067).

Sopel wrote the code to perform just the accumulator update. This PR is based on cleaned up code that

passed STC:
https://tests.stockfishchess.org/tests/view/63f62f9be74a12625bcd4aa0
 LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 110368 W: 29607 L: 29167 D: 51594
Ptnml(0-2): 41, 10551, 33572, 10967, 53

and in an the earlier (equivalent) version

passed STC:
https://tests.stockfishchess.org/tests/view/63f3c3fee74a12625bcce2a6
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 47552 W: 12786 L: 12467 D: 22299
Ptnml(0-2): 120, 5107, 12997, 5438, 114

passed LTC:
https://tests.stockfishchess.org/tests/view/63f45cc2e74a12625bccfa63
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 110368 W: 29607 L: 29167 D: 51594
Ptnml(0-2): 41, 10551, 33572, 10967, 53

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

Bench: 3726250

14 months agoRemove unused macros
Sebastian Buchwald [Sun, 19 Feb 2023 10:25:10 +0000 (11:25 +0100)]
Remove unused macros

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

No functional change

14 months agoAdd support for ARM dot product instructions
Sebastian Buchwald [Tue, 21 Feb 2023 21:18:17 +0000 (22:18 +0100)]
Add support for ARM dot product instructions

The sdot instruction computes (and accumulates) a signed dot product,
which is quite handy for Stockfish's NNUE code. The instruction is
optional for Armv8.2 and Armv8.3, and mandatory for Armv8.4 and above.

The commit adds a new 'arm-dotprod' architecture with enabled dot
product support. It also enables dot product support for the existing
'apple-silicon' architecture, which is at least Armv8.5.

The following local speed test was performed on an Apple M1 with
ARCH=apple-silicon. I had to remove CPU pinning from the benchmark
script. However, the results were still consistent: Checking both
binaries against themselves reported a speedup of +0.0000 and +0.0005,
respectively.

```
Result of 100 runs
==================
base (...ish.037ef3e1) =    1917997  +/- 7152
test (...fish.dotprod) =    2159682  +/- 9066
diff                   =    +241684  +/- 2923

speedup        = +0.1260
P(speedup > 0) =  1.0000

CPU: 10 x arm
Hyperthreading: off
```

Fixes #4193

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

No functional change

14 months agoRemove one `reduction` call
Dubslow [Wed, 15 Feb 2023 00:04:17 +0000 (18:04 -0600)]
Remove one `reduction` call

even though bench is unchanged to depth 28,
due to adjusting depth in singular extensions this might be functional.

STC: https://tests.stockfishchess.org/tests/view/63ec21affe833123fef34153
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 195712 W: 51625 L: 51581 D: 92506
Ptnml(0-2): 504, 20527, 55779, 20513, 533

LTC: https://tests.stockfishchess.org/tests/view/63ed3487fe833123fef375ed
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 32176 W: 8631 L: 8442 D: 15103
Ptnml(0-2): 5, 2794, 10309, 2967, 13

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

Bench 4283297

14 months agoSimplify late countermove bonus condition
Dubslow [Mon, 23 Jan 2023 01:45:46 +0000 (19:45 -0600)]
Simplify late countermove bonus condition

STC: https://tests.stockfishchess.org/tests/view/63d53ac6a67dd929a555e1e2
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 216096 W: 56862 L: 56839 D: 102395
Ptnml(0-2): 648, 24033, 58650, 24082, 635

LTC: https://tests.stockfishchess.org/tests/view/63d7f9a6a67dd929a5565991
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 808512 W: 214060 L: 214610 D: 379842
Ptnml(0-2): 301, 79448, 245293, 78928, 286

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

Bench: 4283297

14 months agoSimplify nnueComplexity calculation.
mstembera [Mon, 13 Feb 2023 01:33:19 +0000 (17:33 -0800)]
Simplify nnueComplexity calculation.

further simplification after https://github.com/official-stockfish/Stockfish/pull/4377

STC https://tests.stockfishchess.org/tests/view/63e02a3773223e7f52ad8190
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 359072 W: 94605 L: 94733 D: 169734
Ptnml(0-2): 994, 39874, 97958, 39686, 1024

LTC https://tests.stockfishchess.org/tests/view/63e3fd12b5f425d71f77002a
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 248424 W: 66020 L: 66030 D: 116374
Ptnml(0-2): 113, 24653, 74689, 24645, 112

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

bench: 4098325

14 months agoFix overflow in add_dpbusd_epi32x2
MinetaS [Mon, 13 Feb 2023 02:54:59 +0000 (11:54 +0900)]
Fix overflow in add_dpbusd_epi32x2

This patch fixes 16bit overflow in *_add_dpbusd_epi32x2 functions,
that can be triggered in rare cases depending on the NNUE weights.

While the code leads to some slowdown on affected architectures
(most notably avx2), the fix is simpler than some of the other
options discussed in
https://github.com/official-stockfish/Stockfish/pull/4394

Code suggested by Sopel97.

Result of "bench 4096 1 30 default depth nnue":

| Architecture        | master    | patch (gcc) | patch (clang) |
|---------------------|-----------|-------------|---------------|
| x86-64-vnni512      | 762122798 | 762122798   | 762122798     |
| x86-64-avx512       | 769723503 | 762122798   | 762122798     |
| x86-64-bmi2         | 769723503 | 762122798   | 762122798     |
| x86-64-ssse3        | 769723503 | 762122798   | 762122798     |
| x86-64              | 762122798 | 762122798   | 762122798     |

Following architectures will experience ~4% slowdown due to an
additional instruction in the middle of hot path:

* x86-64-avx512
* x86-64-bmi2
* x86-64-avx2
* x86-64-sse41-popcnt (x86-64-modern)
* x86-64-ssse3
* x86-32-sse41-popcnt

This patch clearly loses Elo against master with both STC and LTC.

Failed non-regression STC (256bit fix only):
LLR: -2.95 (-2.94,2.94) <-1.75,0.25>
Total: 33528 W: 8769 L: 9049 D: 15710
Ptnml(0-2): 96, 3616, 9600, 3376, 76
https://tests.stockfishchess.org/tests/view/63e6a5b44299542b1e26a485

60+0.6 @ 30000 games:
Elo: -1.67 +-1.7 (95%) LOS: 2.8%
Total: 30000 W: 7848 L: 7992 D: 14160
Ptnml(0-2): 12, 2847, 9436, 2683, 22
nElo: -3.84 +-3.9 (95%) PairsRatio: 0.95
https://tests.stockfishchess.org/tests/view/63e7ac716d0e1db55f35a660

However, a test against nn-a3dc078bafc7.nnue, which is the latest "safe"
network not causing the bug, passed with regular bounds.

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 160456 W: 42658 L: 42175 D: 75623
Ptnml(0-2): 487, 17638, 43469, 18173, 461
https://tests.stockfishchess.org/tests/view/63e89836d62a5d02b0fa82c8

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

No functional change

14 months agoupdate cuckoo link
disservin [Sat, 11 Feb 2023 16:14:16 +0000 (17:14 +0100)]
update cuckoo link

use webarchive to link to the cycle detection paper by Kervinck.

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

No functional change

14 months agoFix build on arm windows
borg323 [Thu, 9 Feb 2023 19:14:59 +0000 (21:14 +0200)]
Fix build on arm windows

avoids the use of _mm_malloc on arm windows.

fixes #4379
closes https://github.com/official-stockfish/Stockfish/pull/4388

No functional change

14 months agoUpdate default net to nn-1337b1adec5b.nnue
Linmiao Xu [Sun, 5 Feb 2023 18:00:30 +0000 (13:00 -0500)]
Update default net to nn-1337b1adec5b.nnue

Created by retraining the master net on a dataset composed of:

* Most of the previous best dataset filtered to remove positions likely having only one good move
* Adding training data from Leela T77 dec2021 rescored with 16tb of 7-piece tablebases

Trained with end lambda 0.7 and max epoch 900. Positions with ply <= 28 were removed from most of the previous best dataset before training began. A new nnue-pytorch trainer param for skipping early plies was used to skip plies <= 24 in the unfiltered and additional Leela T77 parts of the dataset.

```
python easy_train.py \
  --experiment-name leela96-dfrc99-T80octnovT79aprmayT60novdec-eval-filt-v2-T78augsep-12tb-T77dec-16tb-lambda7-sk24 \
  --training-dataset /data/leela96-dfrc99-T80octnovT79aprmayT60novdec-eval-filt-v2-T78augsep-12tb-T77dec-16tb.binpack \
  --nnue-pytorch-branch linrock/nnue-pytorch/easy-train-early-fen-skipping \
  --early-fen-skipping 24 \
  --gpus "0," \
  --start-from-engine-test-net True \
  --start-lambda 1.0 \
  --end-lambda 0.7 \
  --gamma 0.995 \
  --lr 4.375e-4 \
  --tui False \
  --seed $RANDOM \
  --max_epoch 900
```

The depth6 multipv2 search filtering method is the same as the one used for filtering recent best datasets, with a lower eval difference threshold to remove slightly more positions than before. These parts of the dataset were filtered:

* 96% of T60T70wIsRightFarseerT60T74T75T76.binpack
* 99% of dfrc_n5000.binpack
* T80 oct + nov 2022 data, no positions with castling flags, rescored with ~600gb 7p tablebases
* T79 apr + may 2022 data, rescored with 12tb 7p tablebases
* T60 nov + dec 2021 data, rescored with 12tb 7p tablebases

These parts of the dataset were not filtered. Positions with ply <= 24 were skipped during training:

* T78 aug + sep 2022 data, rescored with 12tb 7p tablebases
* 84% of T77 dec 2021 data, rescored with 16tb 7p tablebases

The code and exact evaluation thresholds used for data filtering can be found at:
https://github.com/linrock/Stockfish/tree/tools-filter-multipv2-eval-diff-t2/src/filter

The exact training data used can be found at:
https://robotmoon.com/nnue-training-data/

Local elo at 25k nodes per move:
nn-epoch859.nnue : 3.5 +/ 1.2

Passed STC:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
https://tests.stockfishchess.org/tests/view/63dfeefc73223e7f52ad769f
Total: 219744 W: 58572 L: 58002 D: 103170
Ptnml(0-2): 609, 24446, 59284, 24832, 701

Passed LTC:
https://tests.stockfishchess.org/tests/view/63e268fc73223e7f52ade7b6
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 91256 W: 24528 L: 24121 D: 42607
Ptnml(0-2): 48, 8863, 27390, 9288, 39

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

bench 3841998

14 months agoUpdate `complexityAverage` in all branches of static eval
Dubslow [Sat, 4 Feb 2023 00:18:55 +0000 (18:18 -0600)]
Update `complexityAverage` in all branches of static eval

STC: https://tests.stockfishchess.org/tests/view/63dda49573223e7f52ad0f8c
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 117416 W: 31173 L: 31049 D: 55194
Ptnml(0-2): 290, 12246, 33533, 12328, 311

LTC: https://tests.stockfishchess.org/tests/view/63dfa90873223e7f52ad69b8
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 44416 W: 11924 L: 11744 D: 20748
Ptnml(0-2): 5, 4036, 13968, 4172, 27

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

bench 4758694

14 months agoCleanup and reorder in qsearch
Michael Chaly [Sat, 4 Feb 2023 20:46:44 +0000 (23:46 +0300)]
Cleanup and reorder in qsearch

This patch is a simplification / code normalisation in qsearch.

Adds steps in comments the same way we have in search;

Makes a separate "pruning" stage instead of heuristics randomly being spread over qsearch code;
Reorders pruning heuristics from least taxing ones to more taxing ones;
Removes repeated check for best value not being mated, instead uses 1 check - thus removes some lines of code.
Moves prefetch and move setup after pruning - makes no sense to do them if move will actually get pruned.

Passed non-regression test:
https://tests.stockfishchess.org/tests/view/63dd2c5ff9a50a69252c1413
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 113504 W: 29898 L: 29770 D: 53836
Ptnml(0-2): 287, 11861, 32327, 11991, 286

https://github.com/official-stockfish/Stockfish/pull/4382

Non-functional change.

14 months agoremove unnecessary variable
Disservin [Sat, 4 Feb 2023 13:16:58 +0000 (14:16 +0100)]
remove unnecessary variable

pinned already has to be true for the bitwise &

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

No functional change

15 months agoImprove excluded move logic
pb00067 [Fri, 3 Feb 2023 16:57:19 +0000 (17:57 +0100)]
Improve excluded move logic

PR consists of 2 improvements on nodes with excludeMove:

1. Remove xoring the posKey with make_key(excludedMove)

   Since we never call tte->save anymore with excludedMove,
   the unique left purpose of the xoring was to avoid a TT hit.
   Nevertheless on a normal bench run this produced ~25 false positives
   (key collisions)
   To avoid that we now forbid early TT cutoff's with excludeMove
   Maybe these accesses to TT with xored key caused useless misses
   in the CPU caches (L1, L2 ...)
   Now doing the probe with the same key as the enclosing search does,
   should hit the CPU cache.

2. Don't probe Tablebases with excludedMove.

   This can't be tested on fishtest, but it's obvious that
   tablebases don't deliver any information about suboptimal moves.

Side note:
   Very surprisingly it looks like we cannot use static eval's from
   TT since they slightly differ over time due to changing optimism.
   Attempts to use static eval's from TT did loose about 13 ELO.
   This is something about to investigate.

LTC: https://tests.stockfishchess.org/tests/view/63dc0f8de9d4cdfbe672d0c6
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 44736 W: 12046 L: 11733 D: 20957
Ptnml(0-2): 12, 4212, 13617, 4505, 22

An analogue of this passed STC & LTC
see PR #4374 (thanks Dubslow for reviewing!)

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

Bench: 4758694

15 months agoRemove reduced LMR capture bonus
Muzhen Gaming [Fri, 3 Feb 2023 10:54:30 +0000 (18:54 +0800)]
Remove reduced LMR capture bonus

In LMR, simplify away the reduced capture bonus (i.e. if (capture) bonus /= 6).

Non-regression STC: https://tests.stockfishchess.org/tests/view/63da1da9bbadd17b3787dced
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 28152 W: 7521 L: 7296 D: 13335
Ptnml(0-2): 76, 3069, 7568, 3280, 83

Non-regression LTC: https://tests.stockfishchess.org/tests/view/63da6ad4bbadd17b3787e98c
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 52472 W: 14120 L: 13941 D: 24411
Ptnml(0-2): 16, 5071, 15887, 5242, 20

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

Bench: 4034016

15 months agoSimplify usage of optimism in complexity
Michael Chaly [Fri, 3 Feb 2023 07:52:14 +0000 (10:52 +0300)]
Simplify usage of optimism in complexity

This patch removes one condition in optimism usage in complexity, now negative optimism also impacts it.

Passed STC:
https://tests.stockfishchess.org/tests/view/63d34f43721fe2bff692fb12
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 204920 W: 54343 L: 54309 D: 96268
Ptnml(0-2): 598, 22648, 55897, 22756, 561

Passed LTC:
https://tests.stockfishchess.org/tests/view/63d612a2a67dd929a556075c
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 200712 W: 53207 L: 53172 D: 94333
Ptnml(0-2): 58, 19664, 60901, 19651, 82

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

bench 4204964

15 months agoExpand statistics tools for engine development
MinetaS [Tue, 24 Jan 2023 22:32:02 +0000 (07:32 +0900)]
Expand statistics tools for engine development

This patch adds more debugging slots up to 32 per type and provide tools
to calculate standard deviation and Pearson's correlation coefficient.

However, due to slot being 0 at default, dbg_hit_on(c, b) has to be removed.

Initial idea from snicolet/Stockfish@d8ab604

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

No functional change

15 months agoDo less SEE pruning in qsearch
Michael Chaly [Thu, 2 Feb 2023 10:05:54 +0000 (13:05 +0300)]
Do less SEE pruning in qsearch

Current master prunes all moves with negative SEE values in qsearch.
This patch sets constant negative threshold thus allowing some moves with negative SEE values to be searched.
Value of threshold is completely arbitrary and can be tweaked - also it as function of depth can be tried.
Original idea by author of Alexandria engine.

Passed STC
https://tests.stockfishchess.org/tests/view/63d79a59a67dd929a5564976
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 34864 W: 9392 L: 9086 D: 16386
Ptnml(0-2): 113, 3742, 9429, 4022, 126

Passed LTC
https://tests.stockfishchess.org/tests/view/63d8074aa67dd929a5565bc2
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 91616 W: 24532 L: 24126 D: 42958
Ptnml(0-2): 32, 8840, 27662, 9238, 36

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

Bench: 4010877

15 months agoUpdate WLD model
Joost VandeVondele [Thu, 2 Feb 2023 07:41:32 +0000 (08:41 +0100)]
Update WLD model

update the WLD model with about 400M positions extracted from recent LTC games after the net updates.
This ensures that the 50% win rate is again at 1.0 eval.

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

No functional change.

15 months agoAdd -Wconditional-uninitialized when using Clang
MinetaS [Wed, 1 Feb 2023 15:08:23 +0000 (00:08 +0900)]
Add -Wconditional-uninitialized when using Clang

Add -Wconditional-uninitialized as it is not controlled by -Wall.

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

No functional change

15 months agoDecrease reduction for killer moves with good history
Muzhen Gaming [Wed, 1 Feb 2023 07:44:53 +0000 (15:44 +0800)]
Decrease reduction for killer moves with good history

If move is a main killer and we have a good history, decrease reduction.

STC: https://tests.stockfishchess.org/tests/view/63d38b37721fe2bff693069a
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 46688 W: 12542 L: 12222 D: 21924
Ptnml(0-2): 126, 5013, 12769, 5287, 149

LTC: https://tests.stockfishchess.org/tests/view/63d471e2bde6e5f3cb4be5d3
LLR: 2.93 (-2.94,2.94) <0.50,2.50>
Total: 130976 W: 35033 L: 34555 D: 61388
Ptnml(0-2): 38, 12551, 39833, 13027, 39

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

Bench: 4069938

15 months agoRemove maxNextDepth
MinetaS [Thu, 19 Jan 2023 00:49:42 +0000 (09:49 +0900)]
Remove maxNextDepth

This patch allows full PV search to have double extensions as well when
extension == 1 && doDeeperSearch && doEvenDeeperSearch && !doShallowerSearch
is true, which is extremely rare to occur.

Passed non-regression STC (master 3d2381d):
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 370824 W: 97835 L: 97974 D: 175015
Ptnml(0-2): 1073, 38814, 105731, 38767, 1027
https://tests.stockfishchess.org/tests/view/63c89416a83c702aac08314c

Passed non-regression LTC (master 3d2381d):
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 306048 W: 81173 L: 81237 D: 143638
Ptnml(0-2): 117, 27977, 96901, 27911, 118
https://tests.stockfishchess.org/tests/view/63cc4e84344bb01c191b2658

Bench: 4208265

15 months agoRemove `previousDepth` in favor of `completedDepth + 2`
Dubslow [Sun, 15 Jan 2023 10:08:33 +0000 (04:08 -0600)]
Remove `previousDepth` in favor of `completedDepth + 2`

Beyond the simplification, this could be considered a bugfix from a certain point of view.
However, the effect is very subtle and essentially impossible for users to notice.
5372f81cc8 added about 2 Elo at LTC, but only for second and later `go` commands; now, with
this patch, the first `go` command will also benefit from that gain. Games under time
controls are unaffected (as per the tests).

STC: https://tests.stockfishchess.org/tests/view/63c3d291330c0d3d051d48a8
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 473792 W: 124858 L: 125104 D: 223830
Ptnml(0-2): 1338, 49653, 135063, 49601, 1241

LTC: https://tests.stockfishchess.org/tests/view/63c8cd56a83c702aac083bc9
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 290728 W: 76926 L: 76978 D: 136824
Ptnml(0-2): 106, 27987, 89221, 27953, 97

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

bench 4208265

15 months agoRemove redundant const qualifiers
Sebastian Buchwald [Wed, 25 Jan 2023 21:04:02 +0000 (22:04 +0100)]
Remove redundant const qualifiers

The const qualifiers are already implied by the constexpr qualifiers.

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

No functional change

15 months agoSimplify functions to read/write network parameters
Sebastian Buchwald [Wed, 25 Jan 2023 21:25:18 +0000 (22:25 +0100)]
Simplify functions to read/write network parameters

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

No functional change

15 months agoFixed UCI TB win values
disservin [Mon, 23 Jan 2023 18:32:26 +0000 (19:32 +0100)]
Fixed UCI TB win values

This patch results in search values for a TB win/loss to be reported in a way that does not change with normalization, i.e. will be consistent over time.

A value of 200.00 pawns is now reported upon entering a TB won position. Values smaller than 200.00 relate to the distance in plies from the root to the probed position position,
with 1 cp being 1 ply distance.

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

No functional change

15 months agoRebalance usage of history heuristics in pruning
Michael Chaly [Wed, 25 Jan 2023 05:12:40 +0000 (08:12 +0300)]
Rebalance usage of history heuristics in pruning

This patch has multiple effects:

* history heuristics sum in futility pruning now can't exceed some negative value so futility pruning for moves with negative histories should become slightly less aggressive;

* history heuristics are now used in SEE pruning for quiet moves;

Passed STC:
https://tests.stockfishchess.org/tests/view/63cde339c93e8828d0f02e3a
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 88424 W: 23681 L: 23303 D: 41440
Ptnml(0-2): 258, 9559, 24219, 9899, 277

Passed LTC:
https://tests.stockfishchess.org/tests/view/63ce9009c93e8828d0f04e4f
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 79536 W: 21223 L: 20843 D: 37470
Ptnml(0-2): 22, 7599, 24146, 7979, 22

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

Bench: 4208265

15 months ago`stat_bonus`: replace quadratic with nearly identical line
Dubslow [Fri, 20 Jan 2023 09:02:25 +0000 (03:02 -0600)]
`stat_bonus`: replace quadratic with nearly identical line

passed stc: https://tests.stockfishchess.org/tests/view/63ca58c90eefe8694a0c4eac
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 287960 W: 76146 L: 76201 D: 135613
Ptnml(0-2): 947, 31890, 78307, 31943, 893

passed ltc: https://tests.stockfishchess.org/tests/view/63cc8a51344bb01c191b30f0
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 73784 W: 19559 L: 19402 D: 34823
Ptnml(0-2): 33, 7171, 22327, 7328, 33

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

bench 3990490

15 months agoUpdate default net to nn-bc24c101ada0.nnue
Linmiao Xu [Fri, 20 Jan 2023 15:41:46 +0000 (10:41 -0500)]
Update default net to nn-bc24c101ada0.nnue

Created by retraining the master net with Leela T78 data from Aug+Sep 2022 added to the previous best dataset. Trained with end lambda 0.7 and started with max epoch 800. All positions with ply <= 28 were skipped:

```
python easy_train.py \
  --experiment-name leela95-dfrc96-filt-only-T80octnov-T60novdecT78augsepT79aprmay-12tb7p-sk28-lambda7 \
  --training-dataset /data/leela95-dfrc96-filt-only-T80octnov-T60novdecT78augsepT79aprmay-12tb7p.binpack \
  --nnue-pytorch-branch linrock/nnue-pytorch/misc-fixes-skip-ply-lteq-28 \
  --start-from-engine-test-net True \
  --gpus "0," \
  --start-lambda 1.0 \
  --end-lambda 0.7 \
  --gamma 0.995 \
  --lr 4.375e-4 \
  --tui False \
  --seed $RANDOM \
  --max_epoch 800
```

Around epoch 750, training was manually paused and max epoch increased to 950 before resuming. The additional Leela training data from T78 was prepared in the same way as the previous best dataset.

The exact training data used can be found at:
https://robotmoon.com/nnue-training-data/

While the local elo ratings during this experiment were much lower than in recent master nets, several later epochs had a consistent elo above zero, and this was hypothesized to represent potential strength at slower time controls.

Local elo at 25k nodes per move
leela95-dfrc96-filt-only-T80octnov-T60novdecT78augsepT79aprmay-12tb7p-sk28-lambda7
nn-epoch819.nnue : 0.4 +/- 1.1 (nn-bc24c101ada0.nnue)
nn-epoch799.nnue : 0.3 +/- 1.2
nn-epoch759.nnue : 0.3 +/- 1.1
nn-epoch839.nnue : 0.2 +/- 1.4

Passed STC
https://tests.stockfishchess.org/tests/view/63cabf6f0eefe8694a0c6013
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 41608 W: 11161 L: 10848 D: 19599
Ptnml(0-2): 116, 4496, 11281, 4781, 130

Passed LTC
https://tests.stockfishchess.org/tests/view/63cb1856344bb01c191af263
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 76760 W: 20517 L: 20137 D: 36106
Ptnml(0-2): 34, 7435, 23070, 7799, 42

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

bench 3941848

15 months agoapply if constexpr to additional instances
Jonathan [Wed, 18 Jan 2023 04:30:50 +0000 (21:30 -0700)]
apply if constexpr to additional instances

as a form of documentation, and a hint to the compiler.

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

No functional change

15 months agoRemove precomputed SquareBB
Stephen Touset [Mon, 16 Jan 2023 22:25:47 +0000 (14:25 -0800)]
Remove precomputed SquareBB

Bit-shifting is a single instruction, and should be faster than an array lookup
on supported architectures. Besides (ever so slightly) speeding up the
conversion of a square into a bitboard, we may see minor general performance
improvements due to preserving more of the CPU's existing cache.

passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 47280 W: 12469 L: 12271 D: 22540
Ptnml(0-2): 128, 4893, 13402, 5087, 130
https://tests.stockfishchess.org/tests/view/63c5cfe618c20f4929c5fe46

Small speedup locally:

```
Result of  20 runs
==================
base (./stockfish.master       ) =    1752135  +/- 10943
test (./stockfish.patch        ) =    1763939  +/- 10818
diff                             =     +11804  +/- 4731

speedup        = +0.0067
P(speedup > 0) =  1.0000

CPU: 16 x AMD Ryzen 9 3950X 16-Core Processor
```

Closes https://github.com/official-stockfish/Stockfish/pull/4343

Bench: 4106793

15 months agoUpdate UCI_Elo parameterization
Joost VandeVondele [Sat, 14 Jan 2023 23:23:24 +0000 (00:23 +0100)]
Update UCI_Elo parameterization

The old parameterization (https://github.com/official-stockfish/Stockfish/pull/2225/files) has now become quite inaccurate.
This updates the formula based on updated results with master. The formula is based on a fit of the Elo results for games
played between master at various skill levels, and various versions of the Stash engine, which have been ranked at CCRL.

```
   # PLAYER             :  RATING  ERROR  POINTS  PLAYED   (%)
   1 master-skill-19    :  3191.1   40.4   940.0    1707    55
   2 master-skill-18    :  3170.3   39.3  1343.0    2519    53
   3 master-skill-17    :  3141.3   37.8  2282.0    4422    52
   4 master-skill-16    :  3111.2   37.1  2773.0    5423    51
   5 master-skill-15    :  3069.5   37.2  2728.5    5386    51
   6 master-skill-14    :  3024.8   36.1  2702.0    5339    51
   7 master-skill-13    :  2972.9   35.4  2645.5    5263    50
   8 master-skill-12    :  2923.1   35.0  2653.5    5165    51
   9 master-skill-11    :  2855.5   33.6  2524.0    5081    50
  10 master-skill-10    :  2788.3   32.0  2724.5    5511    49
  11 stash-bot-v25.0    :  2744.0   31.5  1952.5    3840    51
  12 master-skill-9     :  2702.8   30.5  2670.0    5018    53
  13 master-skill-8     :  2596.2   28.5  2669.5    4975    54
  14 stash-bot-v21.0    :  2561.2   30.0  1338.0    3366    40
  15 master-skill-7     :  2499.5   28.5  1934.0    4178    46
  16 stash-bot-v20.0    :  2452.6   27.7  1606.5    3378    48
  17 stash-bot-v19.0    :  2425.3   26.7  1787.0    3365    53
  18 master-skill-6     :  2363.2   26.4  2510.5    4379    57
  19 stash-bot-v17.0    :  2280.7   25.4  2209.0    4378    50
  20 master-skill-5     :  2203.7   25.3  2859.5    5422    53
  21 stash-bot-v15.3    :  2200.0   25.4  1757.0    4383    40
  22 stash-bot-v14      :  2145.9   25.5  2890.0    5167    56
  23 stash-bot-v13      :  2042.7   25.8  2263.5    4363    52
  24 stash-bot-v12      :  1963.4   25.8  1769.5    4210    42
  25 master-skill-4     :  1922.9   25.9  2690.0    5399    50
  26 stash-bot-v11      :  1873.0   26.3  2203.5    4335    51
  27 stash-bot-v10      :  1783.8   27.8  2568.5    4301    60
  28 master-skill-3     :  1742.3   27.8  1909.5    4439    43
  29 master-skill-2     :  1608.4   29.4  2064.5    4389    47
  30 stash-bot-v9       :  1582.6   30.2  2130.0    4230    50
  31 master-skill-1     :  1467.6   31.3  2015.5    4244    47
  32 stash-bot-v8       :  1452.8   31.5  1953.5    3780    52
  33 master-skill-0     :  1320.1   32.9   651.5    2083    31
```

Skill 0 .. 19, now covers CCRL Blitz Elo from 1320 to 3190, approximately.
Indeed, the Elo of stash in this analysis is only to within +- 100 Elo of CCRL,
probably because it depends quite a bit on the opponent pool.

To obtain a skill level for a given Elo number, the above data is fit as a 3rd
degree polynomial Skill(Elo). A quick test confirms the correspondence to the above table:

```
Score of master-elo-2721 vs stash-bot-v21.0: 51 - 16 - 19  [0.703] 86
Elo difference: 150.1 +/- 70.2, LOS: 100.0 %, DrawRatio: 22.1 %
```

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

No functional change.

15 months agoFix asm modifiers in add_dpbusd_epi32x2 implementations
Sebastian Buchwald [Sat, 14 Jan 2023 15:09:31 +0000 (16:09 +0100)]
Fix asm modifiers in add_dpbusd_epi32x2 implementations

The accumulator should be an earlyclobber because it is written before
all input operands are read. Otherwise, the asm code computes a wrong
result if the accumulator shares a register with one of the other input
operands (which happens if we pass in the same expression for the
accumulator and the operand).

Closes https://github.com/official-stockfish/Stockfish/pull/4339

No functional change

15 months agoUpdate default net to nn-1e7ca356472e.nnue
Linmiao Xu [Wed, 11 Jan 2023 15:07:56 +0000 (10:07 -0500)]
Update default net to nn-1e7ca356472e.nnue

Created by retraining the master net on a dataset composed of:

* The Leela-dfrc_n5000.binpack dataset filtered with depth6 multipv2 search to remove positions with only one good move, in addition to removing positions where either of the two best moves are captures
* The same Leela T80 oct+nov 2022 training data used in recent best datasets
* Additional Leela training data from T60 nov+dec 2021 and T79 apr+may 2022

Trained with end lambda 0.7 and started with max epoch 800. All positions with ply <= 28 were skipped:

```
python easy_train.py \
  --experiment-name leela95-dfrc96-mpv-eval-fonly-T80octnov-T79aprmayT60novdec-12tb7p-sk28-lambda7 \
  --training-dataset /data/leela95-dfrc96-mpv-eval-fonly-T80octnov-T79aprmayT60novdec-12tb7p.binpack \
  --nnue-pytorch-branch linrock/nnue-pytorch/misc-fixes-skip-ply-lteq-28 \
  --start-from-engine-test-net True \
  --gpus "0," \
  --start-lambda 1.0 \
  --end-lambda 0.7 \
  --gamma 0.995 \
  --lr 4.375e-4 \
  --tui False \
  --seed $RANDOM \
  --max_epoch 800
```

Around epoch 780, training was manually paused and max epoch increased to 920 before resuming.

During depth6 multipv2 data filtering, positions were considered to have only one good move if the score of the best move was significantly better than the 2nd best move in a way that changes the outcome of the game:

* the best move leads to a significant advantage while the 2nd best move equalizes or loses
* the best move is about equal while the 2nd best move loses

The modified stockfish branch and exact score thresholds used for filtering are at:
https://github.com/linrock/Stockfish/tree/tools-filter-multipv2-eval-diff/src/filter

About 95% of the Leela portion and 96% of the DFRC portion of the Leela-dfrc_n5000.binpack dataset was filtered. Unfiltered parts of the dataset were left out.

The additional Leela training data from T60 nov+dec 2021 and T79 apr+may 2022 was WDL-rescored with about 12TB of syzygy 7-piece tablebases where the material difference is less than around 6 pawns. Best moves were exported to .plain data files during data conversion with the lc0 rescorer.

The exact training data can be found at:
https://robotmoon.com/nnue-training-data/

Local elo at 25k nodes per move
experiment_leela95-dfrc96-mpv-eval-fonly-T80octnov-T79aprmayT60novdec-12tb7p-sk28-lambda7
run_0/nn-epoch899.nnue : 3.8 +/- 1.6

Passed STC
https://tests.stockfishchess.org/tests/view/63bed1f540aa064159b9c89b
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 103344 W: 27392 L: 26991 D: 48961
Ptnml(0-2): 333, 11223, 28099, 11744, 273

Passed LTC
https://tests.stockfishchess.org/tests/view/63c010415705810de2deb3ec
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 21712 W: 5891 L: 5619 D: 10202
Ptnml(0-2): 12, 2022, 6511, 2304, 7

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

bench 4106793

15 months agoAvoid unnecessary string copies
Sebastian Buchwald [Fri, 6 Jan 2023 17:13:21 +0000 (18:13 +0100)]
Avoid unnecessary string copies

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

also fixes typo, closes https://github.com/official-stockfish/Stockfish/pull/4332

No functional change

15 months agoReplace some std::string occurrences with std::string_view
Sebastian Buchwald [Sat, 7 Jan 2023 13:53:59 +0000 (14:53 +0100)]
Replace some std::string occurrences with std::string_view

std::string_view is more lightweight than std::string. Furthermore,
std::string_view variables can be declared constexpr.

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

No functional change

15 months agoModernize code base a little bit
Stefano Di Martino [Sat, 7 Jan 2023 00:08:30 +0000 (01:08 +0100)]
Modernize code base a little bit

Removed sprintf() which generated a warning, because of security reasons.
Replace NULL with nullptr
Replace typedef with using
Do not inherit from std::vector. Use composition instead.
optimize mutex-unlocking

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

No functional change

15 months agoWarn if a global function has no previous declaration
Sebastian Buchwald [Tue, 27 Dec 2022 20:06:10 +0000 (21:06 +0100)]
Warn if a global function has no previous declaration

If a global function has no previous declaration, either the declaration
is missing in the corresponding header file or the function should be
declared static. Static functions are local to the translation unit,
which allows the compiler to apply some optimizations earlier (when
compiling the translation unit rather than during link-time
optimization).

The commit enables the warning for gcc, clang, and mingw. It also fixes
the reported warnings by declaring the functions static or by adding a
header file (benchmark.h).

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

No functional change

15 months agoOnly close file if already open
Jake Senne [Tue, 3 Jan 2023 21:16:45 +0000 (15:16 -0600)]
Only close file if already open

Ensures that the tablebase file is only closed if already open.

Fixes #4268
Closes https://github.com/official-stockfish/Stockfish/pull/4321

No functional change

15 months agoOn step 18 increase reduction by 2 if not ttmove and cutnode
candirufish [Mon, 9 Jan 2023 13:26:51 +0000 (14:26 +0100)]
On step 18 increase reduction by 2 if not ttmove and cutnode

stc: https://tests.stockfishchess.org/tests/view/63babc9fcd3db0c8d399f723
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 43104 W: 11711 L: 11389 D: 20004
Ptnml(0-2): 211, 4518, 11793, 4798, 232

ltc: https://tests.stockfishchess.org/tests/view/63bb1857cd3db0c8d39a0661
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 127104 W: 33810 L: 33339 D: 59955
Ptnml(0-2): 39, 12155, 38702, 12608, 48

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

Bench: 4035725

15 months agoLate countermove bonus: remove "extraBonus &&"
Dubslow [Sat, 24 Dec 2022 15:43:22 +0000 (09:43 -0600)]
Late countermove bonus: remove "extraBonus &&"

passed stc: https://tests.stockfishchess.org/tests/view/63a71e409c0589b83751dc25
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 432480 W: 113846 L: 114055 D: 204579
Ptnml(0-2): 1164, 48205, 117701, 48016, 1154

passed ltc: https://tests.stockfishchess.org/tests/view/63aba66639af998100ce1aa9
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 245344 W: 65309 L: 65317 D: 114718
Ptnml(0-2): 117, 24257, 73903, 24307, 88

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

bench 4379218

16 months agoFix stack initialization
mstembera [Wed, 28 Dec 2022 00:44:32 +0000 (16:44 -0800)]
Fix stack initialization

This fixes a bug where on line 278 the Stack::staticEvals are
initialized to 0. However VALUE_NONE is defined to be 32002 so
this is a bug in master. It is probably due to the calculation
of improvement, where staticEval prior to rootPos can be accessed.

https://tests.stockfishchess.org/tests/view/63ab91cf39af998100ce1666
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 53736 W: 14285 L: 13955 D: 25496
Ptnml(0-2): 121, 5921, 14500, 6159, 167

https://tests.stockfishchess.org/tests/view/63b2af5ee28ed36c814bed52
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 33776 W: 9130 L: 8934 D: 15712
Ptnml(0-2): 14, 3240, 10185, 3434, 15

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

Bench: 4068510

16 months agoParameter Tweaks
FauziAkram [Mon, 2 Jan 2023 14:19:41 +0000 (17:19 +0300)]
Parameter Tweaks

This patch is a parameter tweak that passed both STC and LTC tests.

STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 80944 W: 21557 L: 21189 D: 38198
Ptnml(0-2): 192, 8883, 22028, 9103, 266
https://tests.stockfishchess.org/tests/view/63b07fe2d421d8f75795a03b

LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 30440 W: 8296 L: 8007 D: 14137
Ptnml(0-2): 6, 2893, 9143, 3162, 16
https://tests.stockfishchess.org/tests/view/63b167d02ab1290f961644db

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

Bench: 4182223

16 months agoUpdate default net to nn-a3dc078bafc7.nnue
Linmiao Xu [Thu, 29 Dec 2022 15:34:28 +0000 (10:34 -0500)]
Update default net to nn-a3dc078bafc7.nnue

This is a later epoch (epoch 859) from the same experiment run that trained yesterday's master net nn-60fa44e376d9.nnue (epoch 779). The experiment was manually paused around epoch 790 and unpaused with max epoch increased to 900 mainly to get more local elo data without letting the GPU idle.

nn-60fa44e376d9.nnue is from #4314
nn-335a9b2d8a80.nnue is from #4295

Local elo vs. nn-335a9b2d8a80.nnue at 25k nodes per move:
experiment_leela93-dfrc99-filt-only-T80-oct-nov-skip28
run_0/nn-epoch779.nnue (nn-60fa44e376d9.nnue) : 5.0 +/- 1.2
run_0/nn-epoch859.nnue (nn-a3dc078bafc7.nnue) : 5.6 +/- 1.6

Passed STC vs. nn-335a9b2d8a80.nnue
https://tests.stockfishchess.org/tests/view/63ae10495bd1e5f27f13d94f
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 37536 W: 10088 L: 9781 D: 17667
Ptnml(0-2): 110, 4006, 10223, 4325, 104

An LTC test vs. nn-335a9b2d8a80.nnue was paused due to nn-60fa44e376d9.nnue passing LTC first:
https://tests.stockfishchess.org/tests/view/63ae5d34331d5fca5113703b

Passed LTC vs. nn-60fa44e376d9.nnue
https://tests.stockfishchess.org/tests/view/63af1e41465d2b022dbce4e7
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 148704 W: 39672 L: 39155 D: 69877
Ptnml(0-2): 59, 14443, 44843, 14936, 71

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

bench 3984365

16 months agoUpdate copyright years
Sebastian Buchwald [Sun, 1 Jan 2023 13:45:08 +0000 (14:45 +0100)]
Update copyright years

Happy New Year!

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

No functional change

16 months agoUpdate default net to nn-60fa44e376d9.nnue
Linmiao Xu [Thu, 29 Dec 2022 15:34:28 +0000 (10:34 -0500)]
Update default net to nn-60fa44e376d9.nnue

Created by retraining the master net on the previous best dataset with additional filtering. No new data was added.

More of the Leela-dfrc_n5000.binpack part of the dataset was pre-filtered with depth6 multipv2 search to remove bestmove captures. About 93% of the previous Leela/SF data and 99% of the SF dfrc data was filtered. Unfiltered parts of the dataset were left out. The new Leela T80 oct+nov data is the same as before. All early game positions with ply count <= 28 were skipped during training by modifying the training data loader in nnue-pytorch.

Trained in a similar way as recent master nets, with a different nnue-pytorch branch for early ply skipping:

python3 easy_train.py \
  --experiment-name=leela93-dfrc99-filt-only-T80-oct-nov-skip28 \
  --training-dataset=/data/leela93-dfrc99-filt-only-T80-oct-nov.binpack \
  --start-from-engine-test-net True \
  --nnue-pytorch-branch=linrock/nnue-pytorch/misc-fixes-skip-ply-lteq-28 \
  --gpus="0," \
  --start-lambda=1.0 \
  --end-lambda=0.75 \
  --gamma=0.995 \
  --lr=4.375e-4 \
  --tui=False \
  --seed=$RANDOM \
  --max_epoch=800 \
  --network-testing-threads 20 \
  --num-workers 6

For the exact training data used: https://robotmoon.com/nnue-training-data/
Details about the previous best dataset: #4295

Local testing at a fixed 25k nodes:
experiment_leela93-dfrc99-filt-only-T80-oct-nov-skip28
Local Elo: run_0/nn-epoch779.nnue : 5.1 +/- 1.5

Passed STC
https://tests.stockfishchess.org/tests/view/63adb3acae97a464904fd4e8
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 36504 W: 9847 L: 9538 D: 17119
Ptnml(0-2): 108, 3981, 9784, 4252, 127

Passed LTC
https://tests.stockfishchess.org/tests/view/63ae0ae25bd1e5f27f13d884
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 36592 W: 10017 L: 9717 D: 16858
Ptnml(0-2): 17, 3461, 11037, 3767, 14

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

bench 4015511

16 months agoRemove redundant extern modifier for function declarations
Sebastian Buchwald [Tue, 27 Dec 2022 09:31:24 +0000 (10:31 +0100)]
Remove redundant extern modifier for function declarations

Functions have external linkage by default, so there's no need to
declare them extern.

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

No functional change

16 months agoFix comparison with uninitialized variable
Sebastian Buchwald [Tue, 27 Dec 2022 12:33:26 +0000 (13:33 +0100)]
Fix comparison with uninitialized variable

In both modified methods, the variable 'result' is checked to detect
whether the probe operation failed. However, the variable is not
initialized on all paths, so the check might test an uninitialized
value.

A test position (with TB) is given by:

position fen 3K1k2/R7/8/8/8/8/8/R6Q w - - 0 1 moves a1b1 f8g8 b1a1 g8f8 a1b1 f8g8 b1a1

This is now fixed by always initializing the variable.

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

No functional change

16 months agoAdd double bonus for prior countermove fail low
Muzhen Gaming [Sat, 24 Dec 2022 05:05:24 +0000 (13:05 +0800)]
Add double bonus for prior countermove fail low

Add a double extra bonus for particularly bad fail low cases. Original idea by Yoshie2000.

STC: https://tests.stockfishchess.org/tests/view/63a2f0d86b5bf07ac7fad543
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 146488 W: 38992 L: 38532 D: 68964
Ptnml(0-2): 385, 16036, 39965, 16450, 408

LTC: https://tests.stockfishchess.org/tests/view/63a3eaeb6b5bf07ac7fafdec
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 103992 W: 27853 L: 27423 D: 48716
Ptnml(0-2): 41, 10029, 31435, 10441, 50

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

Bench: 3801857

16 months agoUpdate Elo estimates for terms in search
FauziAkram [Tue, 20 Dec 2022 19:54:12 +0000 (22:54 +0300)]
Update Elo estimates for terms in search

based on 25k games per term, using the UHO_XXL_+0.90_+1.19.epd book, at STC.

More detailed information in the PR.

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

No functional change

16 months agoUpdate default net to nn-335a9b2d8a80.nnue
Linmiao Xu [Mon, 19 Dec 2022 21:10:22 +0000 (16:10 -0500)]
Update default net to nn-335a9b2d8a80.nnue

Created by retraining the master net with a combination of:

    the previous best dataset (Leela-dfrc_n5000.binpack), with about half the dataset filtered using depth6 multipv2 search to throw away positions where either of the 2 best moves are captures
    Leela T80 Oct and Nov training data rescored with best moves, adding ~9.5 billion positions

Trained effectively the same way as the previous master net:

python3 easy_train.py \
  --experiment-name=leela-dfrc-filtered-T80-oct-nov \
  --training-dataset=/data/leela-dfrc-filtered-T80-oct-nov.binpack \
  --start-from-engine-test-net True \
  --gpus="0," \
  --start-lambda=1.0 \
  --end-lambda=0.75 \
  --gamma=0.995 \
  --lr=4.375e-4 \
  --tui=False \
  --seed=$RANDOM \
  --max_epoch=800 \
  --auto-exit-timeout-on-training-finished=900 \
  --network-testing-threads 20 \
  --num-workers 6

Local testing at a fixed 25k nodes:
experiments/experiment_leela-dfrc-filtered-T80-oct-nov/training/run_0/nn-epoch779.nnue
localElo: run_0/nn-epoch779.nnue : 4.7 +/- 3.1

The new Leela T80 part of the dataset was prepared by downloading test80 training data from all of Oct 2022 and Nov 2022, rescoring with syzygy 6-piece tablebases and ~600 GB of 7-piece tablebases, saving best moves to exported .plain files, removing all positions with castling flags, then converting to binpacks and using interleave_binpacks.py to merge them together. Scripts used in this data conversion process are available at:
https://github.com/linrock/lc0-data-converter

Filtering binpack data using depth6 multipv2 search was done by modifying transform.cpp in the tools branch:
https://github.com/linrock/Stockfish/tree/tools-filter-multipv2-no-rescore

Links for downloading the training data (total size: 338 GB) are available at:
https://robotmoon.com/nnue-training-data/

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 30544 W: 8244 L: 7947 D: 14353
Ptnml(0-2): 93, 3243, 8302, 3542, 92
https://tests.stockfishchess.org/tests/view/63a0d377264a0cf18f86f82b

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 32464 W: 8866 L: 8573 D: 15025
Ptnml(0-2): 19, 3054, 9794, 3345, 20
https://tests.stockfishchess.org/tests/view/63a10bc9fb452d3c44b1e016

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

Bench 3554904

16 months agoFix a dependency bug
MinetaS [Tue, 20 Dec 2022 07:01:05 +0000 (16:01 +0900)]
Fix a dependency bug

Instead of allowing .depend for specific build-related targets, filter
non-build-related targets (i.e. help, clean) so that other targets can
normally execute .depend target.

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

No functional change

16 months agoSometimes do a reduced search if LMR is skipped
Alfredo Menezes [Mon, 19 Dec 2022 19:07:09 +0000 (16:07 -0300)]
Sometimes do a reduced search if LMR is skipped

If the node doesn't go through LMR and r is too big,
reduce search depth by one ply.

STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 664888 W: 176375 L: 175169 D: 313344
Ptnml(0-2): 1965, 73754, 179851, 74858, 2016
https://tests.stockfishchess.org/tests/view/6399414c93ed41c57ede8fb8

LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 150784 W: 40553 L: 40031 D: 70200
Ptnml(0-2): 76, 14668, 45387, 15180, 81
https://tests.stockfishchess.org/tests/view/639dee6e11c576d919dc2b38

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

Bench: 3727508

16 months agoNo error if net available but wget/curl missing
Joost VandeVondele [Mon, 19 Dec 2022 16:54:36 +0000 (17:54 +0100)]
No error if net available but wget/curl missing

do not error out on missing wget/curl if these tools are not needed later on,
i.e. if the net is available already.

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

No functional change

16 months agoDon't reset increaseDepth back to true after it has been set to false
mstembera [Tue, 13 Dec 2022 07:22:02 +0000 (23:22 -0800)]
Don't reset increaseDepth back to true after it has been set to false

Resetting increaseDepth back to true each time on the very next iteration was not intended so this is a bug fix and a simplification.
See more discussion here #2482 (comment) Thanks to xoto10

STC: https://tests.stockfishchess.org/tests/view/6398c74693ed41c57ede7bfd
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 51128 W: 13543 L: 13220 D: 24365
Ptnml(0-2): 165, 5363, 14174, 5708, 154

LTC: https://tests.stockfishchess.org/tests/view/6399bcd393ed41c57edea750
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 290864 W: 77282 L: 77334 D: 136248
Ptnml(0-2): 107, 28127, 89029, 28049, 120

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

bench: 3611278

16 months agoReintroduce doEvenDeeperSearch
Michael Chaly [Sat, 17 Dec 2022 09:48:03 +0000 (12:48 +0300)]
Reintroduce doEvenDeeperSearch

This patch is basically the same as a reverted patch
but now has some guarding against search being stuck - the same
way as we do with double extensions. This should help with
search explosions - albeit slowly but they eventually should be resolved.

passed STC:
https://tests.stockfishchess.org/tests/view/639733d0b4e52c95053f3485
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 514048 W: 136423 L: 135435 D: 242190
Ptnml(0-2): 1425, 56945, 139420, 57685, 1549

passed LTC:
https://tests.stockfishchess.org/tests/view/639ab79b93ed41c57eded5c3
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 113800 W: 30642 L: 30190 D: 52968
Ptnml(0-2): 53, 11092, 34178, 11504, 73

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

bench 3611278

16 months agoBadge link fix
PikaCat [Fri, 16 Dec 2022 02:28:31 +0000 (10:28 +0800)]
Badge link fix

Fix the badge link issue mentioned in https://github.com/badges/shields/issues/8671

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

No functional change

16 months agoFixed the help of Makefile
NguyenPham [Thu, 15 Dec 2022 06:29:23 +0000 (17:29 +1100)]
Fixed the help of Makefile

make profile-build more prominent, adjust comments

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

No functional change

16 months agoSimplify Capture Scoring
VoyagerOne [Sun, 11 Dec 2022 17:36:13 +0000 (12:36 -0500)]
Simplify Capture Scoring

The parameters are now in one place for easier tuning.
New formula is very similar to current.

STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 48176 W: 12819 L: 12616 D: 22741
Ptnml(0-2): 139, 5316, 13001, 5467, 165

LTC:
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 176752 W: 47364 L: 47304 D: 82084
Ptnml(0-2): 83, 17302, 53536, 17382, 73
https://tests.stockfishchess.org/tests/view/638ec7d068532fcbf79dfa15

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

Bench: 3410998

16 months agoGitHub Actions: install NDK once and clean up yaml
ppigazzini [Sun, 11 Dec 2022 11:06:22 +0000 (12:06 +0100)]
GitHub Actions: install NDK once and clean up yaml

Use Ubuntu 22.04 as runner for NDK to avoid a qemu bug with `profile-build`

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

No functional change

16 months agoAvoid truncated PV in the threaded case
mstembera [Sat, 10 Dec 2022 02:50:06 +0000 (18:50 -0800)]
Avoid truncated PV in the threaded case

strongly prefer to pick as bestThread those threads with a longer PV,
among those threads that all found the same bestmove.

extended discussion in #4244
closes https://github.com/official-stockfish/Stockfish/pull/4278

No functional change

16 months agoRevert "doEvenDeeperSearch + tuning"
Joost VandeVondele [Mon, 12 Dec 2022 07:12:10 +0000 (08:12 +0100)]
Revert "doEvenDeeperSearch + tuning"

This reverts commit 98965c139df1483a3d684ee8bc7a60dc4b95efa1.

The increase of depth could lead to search explosions,
most visible with TB.

fixes https://github.com/official-stockfish/Stockfish/issues/4276
closes https://github.com/official-stockfish/Stockfish/pull/4256

Bench: 3872306

16 months agoFix lower/upper bounds output
disservin [Fri, 9 Dec 2022 20:48:03 +0000 (21:48 +0100)]
Fix lower/upper bounds output

Commit cb0c7a98485fbef4e5d6ed5f5b08201113ce0b4e doesnt reset the lower/upper bounds back to false.

fixes #4273
closes https://github.com/official-stockfish/Stockfish/pull/4274

No functional change

16 months agoCI workflows, install git on windows
Joost VandeVondele [Fri, 9 Dec 2022 17:24:54 +0000 (18:24 +0100)]
CI workflows, install git on windows

ensures the SF dev version is reported correctly

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

No functional change

16 months agoCI workflows, install git on windows
Joost VandeVondele [Fri, 9 Dec 2022 16:56:55 +0000 (17:56 +0100)]
CI workflows, install git on windows

ensures the SF dev version is reported correctly

No functional change

16 months agoSimplify redundant condition.
Douglas Matos Gomes [Fri, 9 Dec 2022 00:40:07 +0000 (21:40 -0300)]
Simplify redundant condition.

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

No functional change

16 months agoExtend all moves at low depth if ttMove is doubly extended
Alfredo Menezes [Fri, 9 Dec 2022 15:11:43 +0000 (12:11 -0300)]
Extend all moves at low depth if ttMove is doubly extended

If ttMove is doubly extended, we allow a depth growth of the remaining moves.
The idea is to get a more realistic score comparison, because of the depth
difference. We take some care to avoid this extension for high depths,
in order to avoid the cost, since the search result is supposed
to be more accurate in this case.

This pull request includes some small cleanups.

STC:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 60256 W: 16189 L: 15848 D: 28219
Ptnml(0-2): 182, 6546, 16330, 6889, 181
https://tests.stockfishchess.org/tests/view/639109a1792a529ae8f27777

LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 106232 W: 28487 L: 28053 D: 49692
Ptnml(0-2): 46, 10224, 32145, 10652, 49
https://tests.stockfishchess.org/tests/view/63914cba792a529ae8f282ee

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

Bench: 3622368

16 months agoGitHub Action: upload ARM artifacts
ppigazzini [Thu, 8 Dec 2022 19:50:32 +0000 (20:50 +0100)]
GitHub Action: upload ARM artifacts

And some clean up in other files.

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

No functional change

16 months agoInvoke .depend only on build targets
MinetaS [Tue, 6 Dec 2022 12:32:42 +0000 (21:32 +0900)]
Invoke .depend only on build targets

Add a constraint so that the dependency build only occurs when users
actually run build tasks.

This fixes a bug on some systems where gcc/g++ is not available.

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

No functional change

16 months agoCorrectly output lowerbound/upperbound scores
Guenther Demetz [Tue, 6 Dec 2022 18:09:33 +0000 (19:09 +0100)]
Correctly output lowerbound/upperbound scores

fixes the lowerbound/upperbound output by avoiding
scores outside the alpha,beta bracket. Since SF search
uses fail-soft we can't simply take the returned value
as score.

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

No functional change

16 months agodoEvenDeeperSearch + tuning
FauziAkram [Fri, 2 Dec 2022 15:23:28 +0000 (18:23 +0300)]
doEvenDeeperSearch + tuning

Credit for the main idea of doEvenDeeperSearch goes to Vizvezdenec,
tuning by FauziAkram: Expansion of existing logic of doDeeperSearch -
if value from LMR is really really good do full depth search not
1 ply deeper but rather 2 instead.

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 330048 W: 87672 L: 86942 D: 155434
Ptnml(0-2): 1012, 36739, 88912, 37229, 1132
https://tests.stockfishchess.org/tests/view/638a1cadd2b9c924c4c621d2

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 216696 W: 57891 L: 57240 D: 101565
Ptnml(0-2): 72, 21221, 65152, 21790, 113
https://tests.stockfishchess.org/tests/view/638c7d52a971f1f096c68fe2

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

Bench: 3461830

16 months agoSet the right PATH for ARM compiler and build tests in CI
ppigazzini [Thu, 8 Dec 2022 17:32:30 +0000 (18:32 +0100)]
Set the right PATH for ARM compiler and build tests in CI

Fix for the GitHub upgrade:
https://github.com/actions/runner-images/issues/5879
that broke our ARM workflows because it changed the value of
the ANDROID_NDK_HOME variable referenced in our PATH.

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

No functional change

16 months agoRestore development version
Joost VandeVondele [Thu, 8 Dec 2022 19:33:32 +0000 (20:33 +0100)]
Restore development version

No functional change

17 months agoStockfish 15.1
Joost VandeVondele [Sat, 3 Dec 2022 07:50:46 +0000 (08:50 +0100)]
Stockfish 15.1

Official release version of Stockfish 15.1

Bench: 3467381

---

Today, we have the pleasure to announce Stockfish 15.1.

As usual, downloads will be freely available at stockfishchess.org/download

*Elo gain and competition results*

With this release, version 5 of the NNUE neural net architecture has
been introduced, and the training data has been extended to include
Fischer random chess (FRC) positions. As a result, Elo gains are largest
for FRC, reaching up to 50 Elo for doubly randomized FRC[1] (DFRC).
More importantly, also for standard chess this release progressed and
will win two times more game pairs than it loses[2] against
Stockfish 15. Stockfish continues to win in a dominating way[3] all
chess engine tournaments, including the TCEC Superfinal, Cup, FRC, DFRC,
and Swiss as well as the CCC Bullet, Blitz, and Rapid events.

*New evaluation*

This release also introduces a new convention for the evaluation that
is reported by search. An evaluation of +1 is now no longer tied to the
value of one pawn, but to the likelihood of winning the game. With
a +1 evaluation, Stockfish has now a 50% chance of winning the game
against an equally strong opponent. This convention scales down
evaluations a bit compared to Stockfish 15 and allows for consistent
evaluations in the future.

*ChessBase settlement*

In this release period, the Stockfish team has successfully enforced
its GPL license against ChessBase. This has been an intense process that
included filing a lawsuit[4], a court hearing[5], and finally
negotiating a settlement[6] that established that ChessBase infringed on
the license by not distributing the Stockfish derivatives Fat Fritz 2
and Houdini 6 as free software, and that ensures ChessBase will respect
the Free Software principles in the future. This settlement has been
covered by major chess sites (see e.g. lichess.org[7] and chess.com[8]),
and we are proud that it has been hailed as a ‘historic violation
settlement[9]’ by the Software Freedom Conservancy.

*Thank you*

The Stockfish project builds on a thriving community of enthusiasts
(thanks everybody!) that contribute their expertise, time, and resources
to build a free and open-source chess engine that is robust, widely
available, and very strong. We invite our chess fans to join the
fishtest testing framework and programmers to contribute to the
project[10].

The Stockfish team

[1] https://tests.stockfishchess.org/tests/view/638a6170d2b9c924c4c62cb4
[2] https://tests.stockfishchess.org/tests/view/638a4dd7d2b9c924c4c6297b
[3] https://en.wikipedia.org/wiki/Stockfish_(chess)#Competition_results
[4] https://stockfishchess.org/blog/2021/our-lawsuit-against-chessbase/
[5] https://stockfishchess.org/blog/2022/public-court-hearing-soon/
[6] https://stockfishchess.org/blog/2022/chessbase-stockfish-agreement/
[7] https://lichess.org/blog/Y3u1mRAAACIApBVn/settlement-reached-in-stockfish-v-chessbase
[8] https://www.chess.com/news/view/chessbase-stockfish-reach-settlement
[9] https://sfconservancy.org/news/2022/nov/28/sfc-named-trusted-party-in-gpl-case/
[10] https://stockfishchess.org/get-involved/

17 months agoFix bestThread selection
Joost VandeVondele [Mon, 28 Nov 2022 19:59:38 +0000 (20:59 +0100)]
Fix bestThread selection

If multiple threads have the same best move,
pick the thread with the largest contribution to the confidence vote.
This thread will later be used to display PV, so this patch is
about user-friendliness and/or least surprises, it non-functional for playing strenght.

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

No functional change

17 months agoSimply do full sort on captures.
VoyagerOne [Thu, 1 Dec 2022 21:31:35 +0000 (16:31 -0500)]
Simply do full sort on captures.

STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 42712 W: 11413 L: 11203 D: 20096
Ptnml(0-2): 145, 4661, 11544, 4851, 155
https://tests.stockfishchess.org/tests/view/6384df57d2b9c924c4c53900

LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 239072 W: 64065 L: 64067 D: 110940
Ptnml(0-2): 106, 23735, 71859, 23727, 109
https://tests.stockfishchess.org/tests/view/63851120d2b9c924c4c541ee

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

Bench: 3467381

17 months agoRemove PvNode Parameter for cutoff LMR
VoyagerOne [Sun, 27 Nov 2022 17:00:16 +0000 (12:00 -0500)]
Remove PvNode Parameter for cutoff LMR

STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 198520 W: 52673 L: 52632 D: 93215
Ptnml(0-2): 645, 22241, 53499, 22178, 697
https://tests.stockfishchess.org/tests/view/63746e8f9849fa7a36a6698f

LTC:
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 253568 W: 67487 L: 67501 D: 118580
Ptnml(0-2): 109, 25222, 76141, 25198, 114
https://tests.stockfishchess.org/tests/view/63839859d2b9c924c4c4feb7

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

Bench: 3733322

17 months agoCorrectly output lowerbound/upperbound in threaded searches
Guenther Demetz [Tue, 22 Nov 2022 10:07:18 +0000 (11:07 +0100)]
Correctly output lowerbound/upperbound in threaded searches

fixes the lowerbound/upperbound output by taking the alpha,beta bracket
into account also if a bestThread is selected that is different from the master thread.

Instead of keeping track which bounds where used in the specific search,
in this version we simply store the quality (exact, upperbound,
lowerbound) of the score along with the actual score as information on
rootMove.

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

No functional change

17 months agoSimplify both quiet check evasions' conditions
peregrineshahin [Sun, 13 Nov 2022 09:08:17 +0000 (11:08 +0200)]
Simplify both quiet check evasions' conditions

passed Non-regression STC:
https://tests.stockfishchess.org/tests/view/6370b647f1b748d4819e0b64
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 162904 W: 43249 L: 43171 D: 76484
Ptnml(0-2): 491, 17089, 46220, 17155, 497

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

No functional change

17 months agoSkip full depth search in LMR depending on depth
VoyagerOne [Tue, 22 Nov 2022 17:07:33 +0000 (20:07 +0300)]
Skip full depth search in LMR depending on depth

dynamically adjust newDepth, and skip full depth search if newDepth doesn't exceed the previous search depth.
This affects the used newDepth for future searches, and influences the stat bonus for the move.

Passed STC:
https://tests.stockfishchess.org/tests/view/63795500aa34433735bc1cfe
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 112776 W: 30082 L: 29663 D: 53031
Ptnml(0-2): 352, 12453, 30423, 12744, 416

Passed LTC:
https://tests.stockfishchess.org/tests/view/6379ea39aa34433735bc2f9b
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 83576 W: 22559 L: 22169 D: 38848
Ptnml(0-2): 38, 8011, 25303, 8395, 41

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

Bench: 4390318

17 months agoUpdate Top CPU Contributors
Joost VandeVondele [Sat, 19 Nov 2022 09:18:04 +0000 (10:18 +0100)]
Update Top CPU Contributors

list as of 2022-11-19. Thanks!

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

No functional change

17 months agoUpdate WDL model for current SF
Joost VandeVondele [Sat, 19 Nov 2022 12:03:14 +0000 (13:03 +0100)]
Update WDL model for current SF

This updates the WDL model based on the LTC statistics  (2M games).

Relatively small change, note that this also adjusts the NormalizeToPawnValue (now 361),
to keep win prob at 50% for 100cp.

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

No functional change.

17 months agoFix a missing conversion
Joost VandeVondele [Sat, 19 Nov 2022 09:57:08 +0000 (10:57 +0100)]
Fix a missing conversion

This conversion to cp was overlooked.

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

No functional change

17 months agoSimplification away Cutoff Reset
VoyagerOne [Mon, 14 Nov 2022 13:11:27 +0000 (08:11 -0500)]
Simplification away Cutoff Reset

STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 150184 W: 39913 L: 39819 D: 70452
Ptnml(0-2): 493, 16796, 40474, 16782, 547
https://tests.stockfishchess.org/tests/view/63723e9e54d69a2f33911d3c

LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 58880 W: 15890 L: 15717 D: 27273
Ptnml(0-2): 35, 5765, 17659, 5954, 27
https://tests.stockfishchess.org/tests/view/6373baf49849fa7a36a65427

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

Bench: 4035152

17 months agoDo shallower search in case of lmr being not successful enough
Michael Chaly [Thu, 17 Nov 2022 15:31:59 +0000 (18:31 +0300)]
Do shallower search in case of lmr being not successful enough

In case of a move passing LMR but it results being not too far from
the current best search result produce a full depth search with reduced depth.

Original idea by lonfom169 .

Passed STC:
https://tests.stockfishchess.org/tests/view/6373409b54d69a2f33913fbd
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 169504 W: 45351 L: 44848 D: 79305
Ptnml(0-2): 598, 18853, 45353, 19344, 604

Passed LTC:
https://tests.stockfishchess.org/tests/view/6374c58528e3405283eb8d2d
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 51144 W: 13802 L: 13471 D: 23871
Ptnml(0-2): 19, 4928, 15362, 5229, 34

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

bench 4277005

18 months agospeedup CI
disservin [Mon, 7 Nov 2022 17:15:42 +0000 (18:15 +0100)]
speedup CI

Github Actions allows us to use up to 20 workers.
This way we can launch multiple different checks
at the same time and optimize the overall time
the CI takes a bit.

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

No functional change

18 months agoRemove trend
disservin [Thu, 3 Nov 2022 20:53:02 +0000 (21:53 +0100)]
Remove trend

Simplify trend away.

passed Non-regression STC:
https://tests.stockfishchess.org/tests/view/63642a63a90afcecbd1cb887
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 130000 W: 34683 L: 34567 D: 60750
Ptnml(0-2): 455, 14424, 35135, 14522, 464

passed Non-regression LTC:
https://tests.stockfishchess.org/tests/view/636566fda90afcecbd1cded9
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 81592 W: 21938 L: 21787 D: 37867
Ptnml(0-2): 42, 8035, 24490, 8188, 41

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

Bench: 4239512

18 months agoChange versioning and save binaries as CI artifacts
disservin [Sun, 6 Nov 2022 15:17:17 +0000 (16:17 +0100)]
Change versioning and save binaries as CI artifacts

For development versions of Stockfish, the version will now look like
dev-20221107-dca9a0533
indicating a development version, the date of the last commit,
and the git SHA of that commit. If git is not available,
the fallback is the date of compilation. Releases will continue to be
versioned as before.

Additionally, this PR extends the CI to create binary artifacts,
i.e. pushes to master will automatically build Stockfish and upload
the binaries to github.

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

No functional change

18 months agoNormalize evaluation
Joost VandeVondele [Mon, 31 Oct 2022 19:36:43 +0000 (20:36 +0100)]
Normalize evaluation

Normalizes the internal value as reported by evaluate or search
to the UCI centipawn result used in output. This value is derived from
the win_rate_model() such that Stockfish outputs an advantage of
"100 centipawns" for a position if the engine has a 50% probability to win
from this position in selfplay at fishtest LTC time control.

The reason to introduce this normalization is that our evaluation is, since NNUE,
no longer related to the classical parameter PawnValueEg (=208). This leads to
the current evaluation changing quite a bit from release to release, for example,
the eval needed to have 50% win probability at fishtest LTC (in cp and internal Value):

June 2020  :   113cp (237)
June 2021  :   115cp (240)
April 2022 :   134cp (279)
July 2022  :   167cp (348)

With this patch, a 100cp advantage will have a fixed interpretation,
i.e. a 50% win chance. To keep this value steady, it will be needed to update the win_rate_model()
from time to time, based on fishtest data. This analysis can be performed with
a set of scripts currently available at https://github.com/vondele/WLD_model

fixes https://github.com/official-stockfish/Stockfish/issues/4155
closes https://github.com/official-stockfish/Stockfish/pull/4216

No functional change

18 months agoMark variable as potentially unused
Joost VandeVondele [Sat, 5 Nov 2022 08:14:11 +0000 (09:14 +0100)]
Mark variable as potentially unused

fixes CI when compiled with -Werror

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

No functional change