]> git.sesse.net Git - stockfish/log
stockfish
12 months agoAdjust for bookworm compilation.
Steinar H. Gunderson [Sun, 9 Apr 2023 09:38:36 +0000 (11:38 +0200)]
Adjust for bookworm compilation.

12 months agoMerge remote-tracking branch 'upstream/master'
Steinar H. Gunderson [Sun, 9 Apr 2023 09:25:35 +0000 (11:25 +0200)]
Merge remote-tracking branch 'upstream/master'

12 months agoDepth Tweak and tuning
FauziAkram [Wed, 5 Apr 2023 21:35:05 +0000 (00:35 +0300)]
Depth Tweak and tuning

tunes reduction related parameters, and introduces more reduction on found good moves.

credit for this patch goes also to candirufish Yoshie2000 dubslow peregrineshahin Vizvezdenec

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 38424 W: 10346 L: 10040 D: 18038
Ptnml(0-2): 103, 4111, 10473, 4427, 98
https://tests.stockfishchess.org/tests/view/642ca74277ff3301150db511

Passed LTC:
LLR: 2.97 (-2.94,2.94) <0.50,2.50>
Total: 136968 W: 37151 L: 36660 D: 63157
Ptnml(0-2): 43, 13052, 41808, 13533, 48
https://tests.stockfishchess.org/tests/view/642d632377ff3301150dddbe

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

bench: 3672914

12 months agoAssign negative stat bonuses for quiet moves at Pv nodes
Michael Chaly [Wed, 5 Apr 2023 02:48:34 +0000 (05:48 +0300)]
Assign negative stat bonuses for quiet moves at Pv nodes

This patch assigns negative stat bonuses for quiet moves
at pv nodes which are searched at depth greater than
this node assumes, so are extended.

Passed STC:
https://tests.stockfishchess.org/tests/view/6426198bdb43ab2ba6f9cfa2
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 548944 W: 147287 L: 146254 D: 255403
Ptnml(0-2): 1662, 59772, 150671, 60605, 1762

Passed LTC:
https://tests.stockfishchess.org/tests/view/642be4f177ff3301150d892d
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 93352 W: 25400 L: 24994 D: 42958
Ptnml(0-2): 44, 8817, 28547, 9225, 43

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

bench 5044536

12 months agoSimplify away piece count condition for useClassical
Muzhen Gaming [Tue, 4 Apr 2023 23:25:00 +0000 (07:25 +0800)]
Simplify away piece count condition for useClassical

Simplify away the piece count condition for useClassical. In compensation, the psq requirement is increased by 15%.

Also updated the Elo estimate for useClassical, based on recent testing.

Simplification STC:
https://tests.stockfishchess.org/tests/view/642acbb577ff3301150d3ef5
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 51984 W: 13906 L: 13707 D: 24371
Ptnml(0-2): 150, 5638, 14227, 5817, 160

Simplification LTC:
https://tests.stockfishchess.org/tests/view/642b9c5777ff3301150d778a
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 119696 W: 32412 L: 32300 D: 54984
Ptnml(0-2): 53, 11529, 36567, 11651, 48

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

Bench: 5089321

12 months agoParameters Tweak
FauziAkram [Tue, 4 Apr 2023 11:26:29 +0000 (14:26 +0300)]
Parameters Tweak

Passed STC
LLR: 3.22 (-2.94,2.94) <0.00,2.00>
Total: 664048 W: 177526 L: 176301 D: 310221
Ptnml(0-2): 2002, 72968, 180891, 74129, 2034
https://tests.stockfishchess.org/tests/view/64219901db43ab2ba6f901fa

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 77576 W: 21125 L: 20750 D: 35701
Ptnml(0-2): 24, 7350, 23669, 7717, 28
https://tests.stockfishchess.org/tests/view/642abe3377ff3301150d3a16

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

bench: 4522076

12 months agoSimplifiy TM's root complexity
Dubslow [Sat, 1 Apr 2023 23:48:31 +0000 (18:48 -0500)]
Simplifiy TM's root complexity

Also requires moving optimism initialization, this is a very early `evaluate()` call.

STC: https://tests.stockfishchess.org/tests/view/6428c39677ff3301150ca0d7
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 51256 W: 13805 L: 13612 D: 23839
Ptnml(0-2): 145, 5283, 14592, 5450, 158

LTC: https://tests.stockfishchess.org/tests/view/64296ff377ff3301150cc519
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 106968 W: 28951 L: 28830 D: 49187
Ptnml(0-2): 47, 9746, 33789, 9843, 59

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

no functional change

12 months agoRemove unneeded bitboard from MP
Miguel Lahoz [Sun, 2 Apr 2023 09:28:39 +0000 (17:28 +0800)]
Remove unneeded bitboard from MP

Recent simplification has removed the need for an extra bitboard in MP struct.
Use a local variable instead.

STC: Passed Non-regression test
https://tests.stockfishchess.org/tests/view/64294ae677ff3301150cba16
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 64872 W: 17383 L: 17203 D: 30286
Ptnml(0-2): 179, 6675, 18546, 6859, 177

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

No functional change.

13 months agoDecrease Depth more for positions not in TT.
FauziAkram [Sat, 1 Apr 2023 12:22:53 +0000 (15:22 +0300)]
Decrease Depth more for positions not in TT.

If the position is not in TT, decrease depth by 2
or by 4 if the TT entry for the current position was hit
and the stored depth is greater than or equal to the current depth.

Many thanks to Vizvezdenec as the main idea was his.

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 70664 W: 18995 L: 18639 D: 33030
Ptnml(0-2): 228, 7712, 19090, 8080, 222
https://tests.stockfishchess.org/tests/view/64258a8bdb43ab2ba6f9b682

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 85040 W: 23227 L: 22836 D: 38977
Ptnml(0-2): 26, 8115, 25867, 8466, 46
https://tests.stockfishchess.org/tests/view/64262057db43ab2ba6f9d0e7

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

bench: 4380438

13 months agoReplace deprecated icc with icx
Maxim Masiutin [Fri, 31 Mar 2023 15:16:50 +0000 (18:16 +0300)]
Replace deprecated icc with icx

Replace the deprecated Intel compiler icc with its newer icx variant.
This newer compiler is based on clang, and yields good performance.
As before, currently only linux is supported.

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

No functional change

13 months agoSimplify away complexityAverage
MinetaS [Thu, 30 Mar 2023 11:14:30 +0000 (11:14 +0000)]
Simplify away complexityAverage

Instead of tracking the average of complexity values, calculate
complexity of root position at the beginning of the search and use it as
a scaling factor in time management.

Passed non-regression STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 58752 W: 15738 L: 15551 D: 27463
Ptnml(0-2): 164, 6194, 16478, 6371, 169
https://tests.stockfishchess.org/tests/view/6423010edb43ab2ba6f9424a

Passed non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 92872 W: 24865 L: 24729 D: 43278
Ptnml(0-2): 38, 8652, 28929, 8770, 47
https://tests.stockfishchess.org/tests/view/6423c1f0db43ab2ba6f9644f

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

No functional change

13 months agoStringify the git info passed
Joost VandeVondele [Sat, 1 Apr 2023 09:56:49 +0000 (11:56 +0200)]
Stringify the git info passed

avoid escaping the string in the Makefile.

Alternative to https://github.com/official-stockfish/Stockfish/pull/4476

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

No functional change.

13 months agoRemove reduction for moving threatened piece
Muzhen Gaming [Thu, 30 Mar 2023 09:46:15 +0000 (17:46 +0800)]
Remove reduction for moving threatened piece

Simplify away "Decrease reduction if we move a threatened piece".

Running a dbg_hit_on() shows that this line is only called ~0.12% of the time.

Simplification STC: https://tests.stockfishchess.org/tests/view/641ec2dcdb43ab2ba6f88103
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 146128 W: 39168 L: 39070 D: 67890
Ptnml(0-2): 466, 16117, 39830, 16155, 496

Simplification LTC: https://tests.stockfishchess.org/tests/view/64200689db43ab2ba6f8bca8
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 248016 W: 66703 L: 66714 D: 114599
Ptnml(0-2): 105, 24202, 75406, 24189, 106

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

Bench: 4961236

13 months agoMade advanced Windows API calls dynamically linked
Maxim Masiutin [Wed, 29 Mar 2023 09:43:36 +0000 (12:43 +0300)]
Made advanced Windows API calls dynamically linked

Made advanced Windows API calls (those from Advapi32.dll) dynamically
linked to avoid link errors when compiling using
Intel icx compiler for Windows.

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

No functional change

13 months agoImprove compatibility
Maxim Masiutin [Sun, 12 Mar 2023 13:16:51 +0000 (15:16 +0200)]
Improve compatibility

this makes it easier to compile under MSVC, even though we recommend gcc/clang for production compiles at the moment.

In Win32 API, by default, most null-terminated character strings arguments are of wchar_t (UTF16, formerly UCS16-LE) type, i.e. 2 bytes (at least) per character. So, src/misc.cpp should have proper type. Respectively, for src/syzygy/tbprobe.cpp, in Widows, file paths should be std::wstring rather than std::string. However, this requires a very big number of changes, since the config files are also keeping the 8-bit-per-character std::string strings. Therefore, just one change of using 8-byte-per-character CreateFileA make it compile under MSVC.

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

No functional change

13 months agoAllow PvNode in futility pruning for captures.
peregrineshahin [Thu, 23 Mar 2023 10:35:34 +0000 (13:35 +0300)]
Allow PvNode in futility pruning for captures.

Passed non-regression STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 148128 W: 39428 L: 39333 D: 69367
Ptnml(0-2): 492, 16326, 40315, 16457, 474
https://tests.stockfishchess.org/tests/view/641c2dbfdb43ab2ba6f804e8

Passed non-regression LTC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 376256 W: 100906 L: 101039 D: 174311
Ptnml(0-2): 186, 36697, 114494, 36566, 185
https://tests.stockfishchess.org/tests/view/641d33b2db43ab2ba6f83338

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

bench: 4935616

13 months agoClean up repetitive declarations for see_ge
Miguel Lahoz [Mon, 27 Mar 2023 16:06:24 +0000 (00:06 +0800)]
Clean up repetitive declarations for see_ge

The occupied bitboard is only used in one place and is otherwise thrown away.
To simplify use, see_ge function can instead be overloaded.
Repetitive declarations for occupied bitboard can be removed.

Passed non-regression test
https://tests.stockfishchess.org/tests/view/6421c286db43ab2ba6f908eb
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 48912 W: 13196 L: 13001 D: 22715
Ptnml(0-2): 146, 5003, 13967, 5190, 150

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

No functional change.

13 months agoUpdate default net to nn-dabb1ed23026.nnue
Linmiao Xu [Mon, 27 Mar 2023 05:00:54 +0000 (01:00 -0400)]
Update default net to nn-dabb1ed23026.nnue

Created by retraining the master net with these modifications:

* New filtering methods for existing data from T80 sep+oct2022, T79 apr2022, T78 jun+jul+aug+sep2022, T77 dec2021
* Adding new filtered data from T80 aug2022 and T78 apr+may2022
* Increasing early-fen-skipping from 28 to 30

```
python3 easy_train.py \
  --experiment-name leela96-dfrc99-T80novT79mayT60novdec-v2-T80augsepoctT79aprT78aprtosep-v6-T77dec-v3-sk30 \
  --training-dataset /data/leela96-dfrc99-T80novT79mayT60novdec-v2-T80augsepoctT79aprT78aprtosep-v6-T77dec-v3.binpack \
  --nnue-pytorch-branch linrock/nnue-pytorch/misc-fixes \
  --start-from-engine-test-net True \
  --early-fen-skipping 30 \
  --max_epoch 900 \
  --start-lambda 1.0 \
  --end-lambda 0.7 \
  --lr 4.375e-4 \
  --gamma 0.995 \
  --tui False \
  --gpus "0," \
  --seed $RANDOM
```

The v3 filtering used for data from T77dec 2021 differs from v2 filtering in that:

* To improve binpack compression, positions after ply 28 were skipped during training by setting position scores to VALUE_NONE (32002) instead of removing them entirely
* All early-game positions with ply <= 28 were removed to maximize binpack compression
* Only bestmove captures at d6pv2 search were skipped, not 2nd bestmove captures
* Binpack compression was repaired for the remaining positions by effectively replacing bestmoves with "played moves" to maintain contiguous sequences of positions in the training game data

After improving binpack compression, The T77 dec2021 data size was reduced from 95G to 19G.

The v6 filtering used for data from T80augsepoctT79aprT78aprtosep 2022 differs from v2 in that:

* All positions with only one legal move were removed
* Tighter score differences at d6pv2 search were used to remove more positions with only one good move than before
* d6pv2 search was not used to remove positions where the best 2 moves were captures

```
python3 interleave_binpacks.py \
  nn-547-dataset/leela96-eval-filt-v2.binpack \
  nn-547-dataset/dfrc99-eval-filt-v2.binpack \
  nn-547-dataset/test80-nov2022-12tb7p-eval-filt-v2-d6.binpack \
  nn-547-dataset/T79-may2022-12tb7p-eval-filt-v2.binpack \
  nn-547-dataset/T60-nov2021-12tb7p-eval-filt-v2.binpack \
  nn-547-dataset/T60-dec2021-12tb7p-eval-filt-v2.binpack \
  filt-v6/test80-aug2022-16tb7p-filter-v6.binpack \
  filt-v6/test80-sep2022-16tb7p-filter-v6.binpack \
  filt-v6/test80-oct2022-16tb7p-filter-v6.binpack \
  filt-v6/test79-apr2022-16tb7p-filter-v6.binpack \
  filt-v6/test78-aprmay2022-16tb7p-filter-v6.binpack \
  filt-v6/test78-junjulaug2022-16tb7p-filter-v6.binpack \
  filt-v6/test78-sep2022-16tb7p-filter-v6.binpack \
  filt-v3/test77-dec2021-16tb7p-filt-v3.binpack \
  /data/leela96-dfrc99-T80novT79mayT60novdec-v2-T80augsepoctT79aprT78aprtosep-v6-T77dec-v3.binpack
```

The code for the new data filtering methods is available at:
https://github.com/linrock/Stockfish/tree/nnue-data-v3/nnue-data

The code for giving hexword names to .nnue files is at:
https://github.com/linrock/nnue-namer

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-epoch779.nnue : 0.6 +/- 3.1

Passed STC:
https://tests.stockfishchess.org/tests/view/64212412db43ab2ba6f8efb0
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 82256 W: 22185 L: 21809 D: 38262
Ptnml(0-2): 286, 9065, 22067, 9407, 303

Passed LTC:
https://tests.stockfishchess.org/tests/view/64223726db43ab2ba6f91d6c
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 30840 W: 8437 L: 8149 D: 14254
Ptnml(0-2): 14, 2891, 9323, 3177, 15

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

bench 5101970

13 months agoReuse existing functions to read/write array of network parameters
Sebastian Buchwald [Tue, 28 Mar 2023 17:53:43 +0000 (19:53 +0200)]
Reuse existing functions to read/write array of network parameters

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

No functional change

13 months agoRemove non_pawn_material in NNUE::evaluate
MinetaS [Wed, 22 Mar 2023 07:50:55 +0000 (16:50 +0900)]
Remove non_pawn_material in NNUE::evaluate

After "Use NNUE complexity in search, retune related parameters" commit,
the effect of non-pawn material adjustment has been nearly diminished.
This patch removes pos.non_pawn_material as a simplification, which
passed non-regression tests with both STC and LTC.

Passed non-regression STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 75152 W: 20030 L: 19856 D: 35266
Ptnml(0-2): 215, 8281, 20459, 8357, 264
https://tests.stockfishchess.org/tests/view/641ab471db43ab2ba6f7bc58

Passed non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 193864 W: 51870 L: 51829 D: 90165
Ptnml(0-2): 86, 18968, 58794, 18987, 97
https://tests.stockfishchess.org/tests/view/641b4fe6db43ab2ba6f7db96

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

Bench: 5020718

13 months agoSimplify statScore initialization
Michael Chaly [Fri, 24 Mar 2023 04:45:22 +0000 (07:45 +0300)]
Simplify statScore initialization

This patch simplifies initialization of statScore to "always set it up to 0" instead of setting it up to 0 two plies deeper.
Reason for why it was done in previous way partially was because of LMR usage of previous statScore which was simplified long time ago so it makes sense to make in more simple there.

Passed STC:
https://tests.stockfishchess.org/tests/view/641a86d1db43ab2ba6f7b31d
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 115648 W: 30895 L: 30764 D: 53989
Ptnml(0-2): 368, 12741, 31473, 12876, 366

Passed LTC:
https://tests.stockfishchess.org/tests/view/641b1c31db43ab2ba6f7d17a
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 175576 W: 47122 L: 47062 D: 81392
Ptnml(0-2): 91, 17077, 53390, 17141, 89

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

bench 5081969

13 months agoUpdate Elo estimates for terms in search
FauziAkram [Tue, 21 Mar 2023 20:58:25 +0000 (23:58 +0300)]
Update Elo estimates for terms in search

Setting the Elo value of some functions which were not set before.
All tests run at 10+0.1 (STC), 25000 games (Same as #4294).
Book used: UHO_XXL_+0.90_+1.19.epd

Values are rounded to the nearest non-negative integer.

Test links:
https://tests.stockfishchess.org/tests/view/6419ab5b65775d3b539f46c6
https://tests.stockfishchess.org/tests/view/6419adb465775d3b539f4730
https://tests.stockfishchess.org/tests/view/6419ae9c65775d3b539f4756
https://tests.stockfishchess.org/tests/view/6419b03f65775d3b539f47a8
https://tests.stockfishchess.org/tests/view/6419b35d65775d3b539f4860
https://tests.stockfishchess.org/tests/view/6419b6b965775d3b539f48e6
https://tests.stockfishchess.org/tests/view/6419cade65775d3b539f4cd5
https://tests.stockfishchess.org/tests/view/6419cbb565775d3b539f4d01
https://tests.stockfishchess.org/tests/view/6419cc6965775d3b539f4d1e

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

No functional change

13 months agoVerified SEE pruning for capturing and checking moves.
pb00067 [Mon, 20 Mar 2023 07:56:44 +0000 (08:56 +0100)]
Verified SEE pruning for capturing and checking moves.

Patch analyzes field after SEE exchanges concluded with a recapture by
the opponent:
if opponent Queen/Rook/King results under attack after the exchanges, we
consider the move sharp and don't prune it.

Important note:
By accident I forgot to adjust 'occupied' when the king takes part in
the exchanges.
As result of this a move is considered sharp too, when opponent king
apparently can evade check by recapturing.
Surprisingly this seems contribute to patch's strength.

STC:
https://tests.stockfishchess.org/tests/view/640b16132644b62c33947397
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 116400 W: 31239 L: 30817 D: 54344
Ptnml(0-2): 350, 12742, 31618, 13116, 374

LTC:
https://tests.stockfishchess.org/tests/view/640c88092644b62c3394c1c5
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 177600 W: 47988 L: 47421 D: 82191
Ptnml(0-2): 62, 16905, 54317, 17436, 80

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

bench: 5012145

13 months agoRemove 'si' StateInfo variable/parameter.
pb00067 [Mon, 13 Mar 2023 17:32:40 +0000 (18:32 +0100)]
Remove 'si' StateInfo variable/parameter.

Since st is a member of position we don't need to pass it separately as
parameter.

While being there also remove some line in pos_is_ok, where
a copy of StateInfo was made by using default copy constructor and
then verified it's correctedness by doing a memcmp.
There is no point in doing that.

Passed non-regression test
https://tests.stockfishchess.org/tests/view/64098d562644b62c33942b35
LLR: 3.24 (-2.94,2.94) <-1.75,0.25>
Total: 548960 W: 145834 L: 146134 D: 256992
Ptnml(0-2): 1617, 57652, 156261, 57314, 1636

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

No functional change

13 months agoNNUE namespace cleanup
disservin [Mon, 13 Mar 2023 18:35:27 +0000 (19:35 +0100)]
NNUE namespace cleanup

This patch moves the nnue namespace in the appropiate header that correspondes with the definition.
It also makes navigation a bit easier.

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

No functional change

13 months agoFix null move issue
peregrineshahin [Sat, 11 Mar 2023 22:22:55 +0000 (01:22 +0300)]
Fix null move issue

Fix altering for stats landing on B1 Square after a null move and fix considering counter-moves on A1 for root node.

fixes https://github.com/official-stockfish/Stockfish/issues/4333 by preventing calls to from_sq and to_sq functions over null-moves and none-moves.

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

bench: 4980082

13 months agoSmall cleanups
pb00067 [Wed, 1 Mar 2023 09:29:51 +0000 (10:29 +0100)]
Small cleanups

remove some unneeded assignments, typos, incorrect comments, add authors entry.

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

no functional change

13 months agoRemove redundant condition from capture_stage()
mstembera [Sat, 11 Mar 2023 19:51:08 +0000 (11:51 -0800)]
Remove redundant condition from capture_stage()

Change a non functional promotion check to an assert.

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

No functional change

13 months agoFix Makefile for clang 16
Sebastian Buchwald [Sat, 11 Mar 2023 21:08:35 +0000 (22:08 +0100)]
Fix Makefile for clang 16

The clang 16 release will remove the -fexperimental-new-pass-manager
flag (see https://github.com/llvm/llvm-project/commit/69b2b7282e92a1b576b7bd26f3b16716a5027e8e).
Thus, the commit adapts the Makefile to use this flag only for older
clang versions.

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

No functional change

13 months agoChange mode of incbin.h
Alfredo Menezes [Mon, 13 Mar 2023 01:29:07 +0000 (22:29 -0300)]
Change mode of incbin.h

Keep incbin.h with the same mode as the other source files.

A mode diff might show up when working with patch files or sending the source code between devices.
This patch should fix such behaviour.

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

No functional change

13 months agoDo more singular extensions
Michael Chaly [Mon, 13 Mar 2023 12:57:58 +0000 (15:57 +0300)]
Do more singular extensions

This patch continues trend of last VLTC tuning - as measured by dubslow
most of it gains was in lowering marging in calculation of singularBeta.
This patch is a manual adjustment on top of it - it lowers multiplier
of depth in calculation of singularBeta even further, from 2/3 to 1,5/2,5.

Was negative at STC:
https://tests.stockfishchess.org/tests/view/64089c632644b62c3393fc12
Elo: -2.49 +-1.7 (95%) LOS: 0.2%
Total: 40000 W: 10601 L: 10888 D: 18511
Ptnml(0-2): 123, 4580, 10875, 4305, 117
nElo: -5.03 +-3.4 (95%) PairsRatio: 0.94

Passed 180+1.8 SPRT:
https://tests.stockfishchess.org/tests/view/640096dae74a12625bcf3b33
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 160952 W: 43753 L: 43342 D: 73857
Ptnml(0-2): 25, 13984, 52039, 14411, 17

Passed 60+0.6 8 threads SPRT:
https://tests.stockfishchess.org/tests/view/640dca8e65775d3b539cb7f6
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 38824 W: 10825 L: 10554 D: 17445
Ptnml(0-2): 0, 2939, 13268, 3200, 5

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

bench 4776866

13 months agoMore negative extensions on nonsingular nonpv nodes.
Dubslow [Fri, 10 Mar 2023 00:33:13 +0000 (18:33 -0600)]
More negative extensions on nonsingular nonpv nodes.

Following up the previous gainer also in this nonsingular node
section of code. Credit shared with @FauziAkram for realizing
this nonsingular node stuff had some potential, and @XInTheDark
for reminding us that !PvNodes better handle extensions/reductions
than Pv.

Passed STC: https://tests.stockfishchess.org/tests/view/640a7bb32644b62c339457c3
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 136776 W: 36598 L: 36149 D: 64029
Ptnml(0-2): 439, 14834, 37384, 15301, 430

Passed LTC: https://tests.stockfishchess.org/tests/view/640c43a02644b62c3394b23c
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 79536 W: 21363 L: 20984 D: 37189
Ptnml(0-2): 28, 7525, 24285, 7900, 30

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

Bench: 4444953

13 months agoDo more negative extensions
Michael Chaly [Mon, 6 Mar 2023 22:54:20 +0000 (01:54 +0300)]
Do more negative extensions

This patch does negatively extend transposition table move if singular search failed and tt value is not bigger than alpha.
Logic is close to what we had before recent simplification of negative extensions but uses or condition instead of and condition.

Passed STC:
https://tests.stockfishchess.org/tests/view/6404c8102644b62c33934607
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 119040 W: 31841 L: 31416 D: 55783
Ptnml(0-2): 356, 13070, 32292, 13397, 405

Passed LTC:
https://tests.stockfishchess.org/tests/view/6405abda2644b62c33937119
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 47216 W: 12816 L: 12496 D: 21904
Ptnml(0-2): 12, 4500, 14286, 4776, 34

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

bench 4747020

13 months agoFix TB after capture_stage fix
Joost VandeVondele [Sun, 5 Mar 2023 16:26:12 +0000 (17:26 +0100)]
Fix TB after capture_stage fix

https://github.com/official-stockfish/Stockfish/commit/5c75c1c2fbb7bb4f0bf7c44fb855c415b788cbf7
introduced a capture_stage() function, but TB usage needs a pure capture() function.

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

No functional change.

13 months agoClarify the description of the x86-64-vnni256 and x86-64-avxvnni architectures
Maxim Masiutin [Sun, 5 Mar 2023 15:10:52 +0000 (17:10 +0200)]
Clarify the description of the x86-64-vnni256 and x86-64-avxvnni architectures

Now it is clearly explained that "x86-64-vnni256" requires full
support of AVX512-VNNI, but only 256-bit operands are used.

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

No functional change

13 months agoAdd CITATION.cff file
Joost VandeVondele [Sat, 4 Mar 2023 17:14:23 +0000 (18:14 +0100)]
Add CITATION.cff file

Make the stockfish software more easily citable, for example in academic papers.

fixes https://github.com/official-stockfish/Stockfish/issues/4419
closes https://github.com/official-stockfish/Stockfish/pull/4422

No functional change

13 months agoUpdate README.md
dav1312 [Sat, 4 Mar 2023 12:24:35 +0000 (13:24 +0100)]
Update README.md

Update and simplify the readme, removing duplicated and outdated stuff and pointing to the new wiki

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

No functional change

13 months agoAdd wiki to artifacts
disservin [Sat, 4 Mar 2023 15:34:34 +0000 (16:34 +0100)]
Add wiki to artifacts

snapshot the wiki https://github.com/official-stockfish/stockfish/wiki as part of the artifacts generated.
This will allow future release to include the wiki pages as a form of documentation

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

No functional change

13 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

14 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

14 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

14 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

14 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

14 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

14 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.

14 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

14 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

15 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

15 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

15 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

15 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 agoMerge remote-tracking branch 'upstream/master'
Steinar H. Gunderson [Mon, 26 Dec 2022 08:41:43 +0000 (09:41 +0100)]
Merge remote-tracking branch 'upstream/master'

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