]> git.sesse.net Git - stockfish/log
stockfish
2 years agoRead NNUE net faster
Tomasz Sobczyk [Wed, 9 Jun 2021 09:21:55 +0000 (11:21 +0200)]
Read NNUE net faster

Load feature transformer weights in bulk on little-endian machines.
This is in particular useful to test new nets with c-chess-cli,
see https://github.com/lucasart/c-chess-cli/issues/44

```
$ time ./stockfish.exe uci

Before : 0m0.914s
After  : 0m0.483s
```

No functional change

2 years agoLimit double extensions
Joost VandeVondele [Wed, 9 Jun 2021 21:23:13 +0000 (23:23 +0200)]
Limit double extensions

Double extensions can lead to search explosions, for specific positions.
Currently, however, these double extensions are worth about 10Elo and cannot
be removed. This patch instead limits the number of double extensions given
to a maximum of 3.

This fixes https://github.com/official-stockfish/Stockfish/issues/3532
where the following testcase was shown to be problematic:

```
uci
setoption name Hash value 4
setoption name Contempt value 0
ucinewgame
position fen 8/Pk6/8/1p6/8/P1K5/8/6B1 w - - 37 130
go depth 20
```

passed STC:
https://tests.stockfishchess.org/tests/view/60c13161457376eb8bcaaa0f
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 73256 W: 6114 L: 6062 D: 61080
Ptnml(0-2): 222, 4912, 26306, 4968, 220

passed LTC:
https://tests.stockfishchess.org/tests/view/60c196fb457376eb8bcaaa6b
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 166440 W: 5559 L: 5594 D: 155287
Ptnml(0-2): 106, 4921, 73197, 4894, 102

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

Bench: 5067605

2 years agoSimplify promotion move generator
bmc4 [Mon, 7 Jun 2021 18:47:37 +0000 (15:47 -0300)]
Simplify promotion move generator

This patch removes Knight promotion checks from Captures. As a consequence,
it also removes this underpromotion from qsearch.

STC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 37776 W: 3113 L: 3023 D: 31640
Ptnml(0-2): 103, 2419, 13755, 2507, 104
https://tests.stockfishchess.org/tests/view/60be6a06457376eb8bcaa775

LTC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 39760 W: 1257 L: 1203 D: 37300
Ptnml(0-2): 11, 1079, 17646, 1133, 11
https://tests.stockfishchess.org/tests/view/60beb972457376eb8bcaa7c5

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

Bench: 5530620

2 years agoReduce in LMR reduction on PvNode
bmc4 [Sun, 6 Jun 2021 16:31:57 +0000 (13:31 -0300)]
Reduce in LMR reduction on PvNode

reduce reduction in LMR by 1 on PvNode.

STC:
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 266080 W: 22438 L: 21996 D: 221646
Ptnml(0-2): 774, 17874, 95376, 18168, 848
https://tests.stockfishchess.org/tests/view/60bc0661457376eb8bcaa4bb

LTC:
LLR: 2.93 (-2.94,2.94) <0.50,3.50>
Total: 20144 W: 698 L: 587 D: 18859
Ptnml(0-2): 2, 529, 8906, 626, 9
https://tests.stockfishchess.org/tests/view/60bcc3f2457376eb8bcaa58d

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

bench: 5173012

2 years agoMakefile: Extend sanitize support
Guy Vreuls [Thu, 3 Jun 2021 14:46:05 +0000 (16:46 +0200)]
Makefile: Extend sanitize support

Enable compiling with multiple sanitizers at once.

Syntax:
make build ARCH=x86-64-avx512 debug=on sanitize="address undefined"

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

No functional change.

2 years agoEnhance CI to error on leaks
Joost VandeVondele [Thu, 3 Jun 2021 17:18:24 +0000 (19:18 +0200)]
Enhance CI to error on leaks

Add flags to valgrind in our Continuous Integration scripts,
to error on memory leaks.

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

No functional change.

2 years agoRevert "Simplify En Passant"
Guy Vreuls [Fri, 4 Jun 2021 10:20:27 +0000 (12:20 +0200)]
Revert "Simplify En Passant"

This reverts commit 9f8058bd26df1c3ca37b85f811026f1eb82e6524.

Fixes the memory leak discussed in pull request #3523
https://github.com/official-stockfish/Stockfish/pull/3523

Passed non-regression STC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 76184 W: 6330 L: 6282 D: 63572
Ptnml(0-2): 202, 5047, 27564, 5059, 220
https://tests.stockfishchess.org/tests/view/60ba146c457376eb8bcaa2e2

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

Benched to verify there is no functional change.

Bench: 4364128

2 years agoClean SIMD code a bit
Stéphane Nicolet [Fri, 4 Jun 2021 11:56:40 +0000 (13:56 +0200)]
Clean SIMD code a bit

Cleaner vector code structure in feature transformer. This patch just
regroups the parts of the inner loop for each SIMD instruction set.

Tested for non-regression:
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 115760 W: 9835 L: 9831 D: 96094
Ptnml(0-2): 326, 7776, 41715, 7694, 369
https://tests.stockfishchess.org/tests/view/60b96b39457376eb8bcaa26e

It would be nice if a future patch could use some of the macros at
the top of the file to unify the code between the distincts SIMD
instruction sets (of course, unifying the Relu will be the challenge).

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

No functional change

2 years agoMakefile: better "make clean" for Windows
Stéphane Nicolet [Wed, 2 Jun 2021 06:10:54 +0000 (08:10 +0200)]
Makefile: better "make clean" for Windows

Make clean should be really clean on Windows.

Fixes issue https://github.com/official-stockfish/Stockfish/issues/3291
Closes https://github.com/official-stockfish/Stockfish/pull/3517

No functional change

2 years agoIntroducing NodeType Root
bmc4 [Thu, 3 Jun 2021 16:52:39 +0000 (13:52 -0300)]
Introducing NodeType Root

We transform rootNode into constexpr by adding a new NodeType `Root`,
which causes a speed up.

Local test:
```
Build Tester: 1.4.7.0
Windows 10 (Version 10.0, Build 0, 64-bit Edition)
Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
SafeMode: No
Running In VM: No
HyperThreading Enabled: Yes
CPU Warmup: Yes
Command Line: bench
Tests per Build: 25
ANOVA: n/a

                Engine# (NPS)                     Speedup     Sp     Conf. 95%    S.S.
patch  (920.179,4) ---> master  (906.329,2)  --->  1,528%  20.336,5     Yes        No
```

---------

STC:
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 98216 W: 8348 L: 8102 D: 81766
Ptnml(0-2): 295, 6357, 35549, 6621, 286
https://tests.stockfishchess.org/tests/view/60b797e2457376eb8bcaa0ab

Yellow LTC:
LLR: -2.95 (-2.94,2.94) <0.50,3.50>
Total: 76936 W: 2651 L: 2626 D: 71659
Ptnml(0-2): 29, 2233, 33916, 2264, 26
https://tests.stockfishchess.org/tests/view/60b80d6d457376eb8bcaa145

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

No functional change

2 years agoMake extra time for bestMoveInstability dependent on rootdepth.
xoto10 [Thu, 3 Jun 2021 18:46:55 +0000 (19:46 +0100)]
Make extra time for bestMoveInstability dependent on rootdepth.

This change allocates more base time to moves and makes the additional time added for best move instability dependent on rootdepth.

STC 10+0.1 :
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 19432 W: 1711 L: 1553 D: 16168
Ptnml(0-2): 47, 1250, 6989, 1358, 72
https://tests.stockfishchess.org/tests/view/60b8cd41457376eb8bcaa1ad

LTC 60+0.6 :
LLR: 2.93 (-2.94,2.94) <0.50,3.50>
Total: 22480 W: 810 L: 693 D: 20977
Ptnml(0-2): 9, 603, 9902, 714, 12
https://tests.stockfishchess.org/tests/view/60b8e5bf457376eb8bcaa1e6

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

Bench 4364128

2 years agoUpdate default net to nn-7e66505906a6.nnue
Joost VandeVondele [Thu, 3 Jun 2021 11:53:28 +0000 (13:53 +0200)]
Update default net to nn-7e66505906a6.nnue

Trained with pytorch using the master branch and recommended settings,
the data used is the previous 64B binpack enhanced with a 2B binpack
generated using an opening book of positions for with the static eval
is significantly different from d9 search.

book           : https://drive.google.com/file/d/1rHcKY5rv34kwku6g89OhnE8Bkfq3UWau/view?usp=sharing
book generation: https://github.com/vondele/Stockfish/commit/3ce43ab0c4ce09c1fc5bca5ca27a248e67fddd24
binpack        : https://drive.google.com/file/d/1rHcKY5rv34kwku6g89OhnE8Bkfq3UWau/view?usp=sharing

-------

Data generation command:

generate_training_data depth 9 count 31250000 random_multi_pv 2 random_multi_pv_diff 100 random_move_max_ply 8 random_move_count 3 set_recommended_uci_options eval_limit 32000 output_file_name output.binpack book wrongNNUE.epd seed ${RANDOM}${RANDOM}

Training command:

python train.py ../../all_d9_fishd9_d8_d10_wrong_shuffle.binpack ../../all_d9_fishd9_d8_d10_wrong_shuffle.binpack  --gpus 1 --threads 2 --num-workers 2 --batch-size 16384 --progress_bar_refresh_rate 300 --smart-fen-skipping --random-fen-skipping 3 --features=HalfKAv2^   --lambda=1.0  --max_epochs=400 --seed $RANDOM --default_root_dir exp/run_5

-------

passed STC:
https://tests.stockfishchess.org/tests/view/60b7c79a457376eb8bcaa104
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 64592 W: 6254 L: 6028 D: 52310
Ptnml(0-2): 255, 4785, 22020, 4951, 285

passed LTC:
https://tests.stockfishchess.org/tests/view/60b85307457376eb8bcaa182
LLR: 2.96 (-2.94,2.94) <0.50,3.50>
Total: 45560 W: 1998 L: 1826 D: 41736
Ptnml(0-2): 36, 1604, 19335, 1762, 43

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

Bench: 4364128

2 years agoTypography change for bench
Stéphane Nicolet [Wed, 2 Jun 2021 06:37:00 +0000 (08:37 +0200)]
Typography change for bench

2 years agoRemove formerPV variable.
Stefan Geschwentner [Mon, 31 May 2021 18:26:05 +0000 (20:26 +0200)]
Remove formerPV variable.

STC:
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 75672 W: 6546 L: 6496 D: 62630
Ptnml(0-2): 238, 5274, 26761, 5326, 237
https://tests.stockfishchess.org/tests/view/60b349c0ec0c03148cbed055

LTC:
LLR: 2.98 (-2.94,2.94) <-2.50,0.50>
Total: 137816 W: 4676 L: 4689 D: 128451
Ptnml(0-2): 52, 4237, 60354, 4202, 63
https://tests.stockfishchess.org/tests/view/60b38970ec0c03148cbed075

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

Bench: 4892288

2 years agoPre-initialize ss->ply
J. Oster [Mon, 31 May 2021 15:46:40 +0000 (17:46 +0200)]
Pre-initialize ss->ply

We pre-initialize ss->ply over the whole stack. There is no need
to re-assign the same value(s) over and over again while searching.
Probably a tiny speedup on longer searches.

Tested for no regression:

STC
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 25784 W: 2205 L: 2101 D: 21478
Ptnml(0-2): 62, 1660, 9368, 1716, 86
https://tests.stockfishchess.org/tests/view/60b516c6457376eb8bca9dfa

LTC
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 26200 W: 944 L: 878 D: 24378
Ptnml(0-2): 12, 732, 11545, 800, 11
https://tests.stockfishchess.org/tests/view/60b53652457376eb8bca9e0e

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

No functional change.

2 years agoCheck Extension with Static Evaluation
candirufish [Mon, 31 May 2021 04:47:35 +0000 (06:47 +0200)]
Check Extension with Static Evaluation

extension for checking moves, at higher depth and more decisive positions.

stc:
LLR: 2.97 (-2.94,2.94) <-0.50,2.50>
Total: 87008 W: 7337 L: 7100 D: 72571
Ptnml(0-2): 264, 5737, 31270, 5964, 269
https://tests.stockfishchess.org/tests/view/60b1034787a1a67ae56c47b6

ltc:
LLR: 2.94 (-2.94,2.94) <0.50,3.50>
Total: 79320 W: 2629 L: 2432 D: 74259
Ptnml(0-2): 29, 2205, 35000, 2392, 34
https://tests.stockfishchess.org/tests/view/60b1ae0b87a1a67ae56c487c

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

Bench: 4447112

2 years agoFix export of the feature transformer.
Tomasz Sobczyk [Sat, 29 May 2021 09:40:40 +0000 (11:40 +0200)]
Fix export of the feature transformer.

PSQT export was missing.

fixes #3507

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

No functional change

2 years agoSimplify NNUE / classical evaluation selection
Joost VandeVondele [Sat, 29 May 2021 13:44:57 +0000 (15:44 +0200)]
Simplify NNUE / classical evaluation selection

for the new network architecture these rules can be simplified,
closer to the original PSQT difference based again.

passed STC
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 22656 W: 1979 L: 1868 D: 18809
Ptnml(0-2): 70, 1496, 8087, 1603, 72
https://tests.stockfishchess.org/tests/view/60b24579db3c4776cb89d122

passed LTC
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 30224 W: 1015 L: 953 D: 28256
Ptnml(0-2): 4, 860, 13330, 906, 12
https://tests.stockfishchess.org/tests/view/60b27613db3c4776cb89d145

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

Bench: 3937626

2 years agoRemove Stat Reset at beta cutoff
VoyagerOne [Thu, 27 May 2021 20:03:56 +0000 (16:03 -0400)]
Remove Stat Reset at beta cutoff

STC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 63936 W: 5350 L: 5288 D: 53298
Ptnml(0-2): 184, 4295, 22954, 4345, 190
https://tests.stockfishchess.org/tests/view/60affb4c12066fd299795c64

LTC:
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 35856 W: 1201 L: 1142 D: 33513
Ptnml(0-2): 7, 1031, 15795, 1086, 9
https://tests.stockfishchess.org/tests/view/60b0537812066fd299795cc6

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

bench: 3831936

2 years agoDo not use lazy evaluation inside NNUE
Stéphane Nicolet [Wed, 26 May 2021 23:10:00 +0000 (01:10 +0200)]
Do not use lazy evaluation inside NNUE

This simplification patch implements two changes:

1. it simplifies away the so-called "lazy" path in the NNUE evaluation internals,
   where we trusted the psqt head alone to avoid the costly "positional" head in
   some cases;
2. it raises a little bit the NNUEThreshold1 in evaluate.cpp (from 682 to 800),
   which increases the limit where we switched from NNUE eval to Classical eval.

Both effects increase the number of positional evaluations done by our new net
architecture, but the results of our tests below seem to indicate that the loss
of speed will be compensated by the gain of eval quality.

STC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 26280 W: 2244 L: 2137 D: 21899
Ptnml(0-2): 72, 1755, 9405, 1810, 98
https://tests.stockfishchess.org/tests/view/60ae73f112066fd299795a51

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 20592 W: 750 L: 677 D: 19165
Ptnml(0-2): 9, 614, 8980, 681, 12
https://tests.stockfishchess.org/tests/view/60ae88e812066fd299795a82

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

Bench: 3817907

2 years agoLess reduction for capture/promotions.
Stefan Geschwentner [Wed, 26 May 2021 14:17:37 +0000 (16:17 +0200)]
Less reduction for capture/promotions.

Exclude captures/promotions at expected cut nodes (which also not a
former PV node) from LMR if a response to the first previous
opponent move.

STC:
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 288656 W: 24886 L: 24413 D: 239357
Ptnml(0-2): 900, 19738, 102578, 20213, 899
https://tests.stockfishchess.org/tests/view/60ad505112066fd29979595b

LTC:
LLR: 2.97 (-2.94,2.94) <0.50,3.50>
Total: 31344 W: 1107 L: 975 D: 29262
Ptnml(0-2): 12, 879, 13757, 1013, 11
https://tests.stockfishchess.org/tests/view/60adffce12066fd2997959d2

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

Bench: 3827710

2 years agoSimplify the thread term for reduction formula
IIvec [Thu, 20 May 2021 18:02:32 +0000 (20:02 +0200)]
Simplify the thread term for reduction formula

Dependance on Threads.size() was removed Search::init() for the Reductions[] initialization.

STC:
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 17376 W: 1024 L: 929 D: 15423
Ptnml(0-2): 24, 781, 6989, 864, 30
https://tests.stockfishchess.org/tests/view/60ac110812066fd2997957dc

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 145552 W: 3656 L: 3673 D: 138223
Ptnml(0-2): 37, 3351, 66014, 3340, 34
https://tests.stockfishchess.org/tests/view/60ac267412066fd299795825

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

Bench 3864295

2 years agoExpose the lazy threshold for the feature transformer PSQT as a parameter.
Tomasz Sobczyk [Tue, 25 May 2021 11:09:40 +0000 (13:09 +0200)]
Expose the lazy threshold for the feature transformer PSQT as a parameter.

Definition of the lazy threshold moved to evaluate.cpp where all others are.
Lazy threshold only used for real searches, not used for the "eval" call.
This preserves the purity of NNUE evaluation, which is useful to verify
consistency between the engine and the NNUE trainer.

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

No functional change

2 years agoIncreased reduction for captures in LMR
bmc4 [Mon, 24 May 2021 11:15:04 +0000 (08:15 -0300)]
Increased reduction for captures in LMR

It now does, in LMR, an increased on reduction by 1 for captures in cut nodes.

STC:
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 30656 W: 2565 L: 2397 D: 25694
Ptnml(0-2): 63, 2012, 11029, 2142, 82
https://tests.stockfishchess.org/tests/view/60a96733ce8ea25a3ef04178

LTC:
LLR: 2.93 (-2.94,2.94) <0.50,3.50>
Total: 124840 W: 4139 L: 3878 D: 116823
Ptnml(0-2): 48, 3480, 55100, 3747, 45
https://tests.stockfishchess.org/tests/view/60a995f5ce8ea25a3ef041b7

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

bench: 3864295

2 years agoSometimes change the (materialist, positional) balance
Stéphane Nicolet [Sat, 22 May 2021 17:44:15 +0000 (19:44 +0200)]
Sometimes change the (materialist, positional) balance

Our new nets output two values for the side to move in the last layer.
We can interpret the first value as a material evaluation of the
position, and the second one as the dynamic, positional value of the
location of pieces.

This patch changes the balance for the (materialist, positional) parts
of the score from (128, 128) to (121, 135) when the piece material is
equal between the two players, but keeps the standard (128, 128) balance
when one player is at least an exchange up.

Passed STC:
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 15936 W: 1421 L: 1266 D: 13249
Ptnml(0-2): 37, 1037, 5694, 1134, 66
https://tests.stockfishchess.org/tests/view/60a82df9ce8ea25a3ef0408f

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,3.50>
Total: 13904 W: 516 L: 410 D: 12978
Ptnml(0-2): 4, 374, 6088, 484, 2
https://tests.stockfishchess.org/tests/view/60a8bbf9ce8ea25a3ef04101

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

Bench: 3856635

2 years agoTuning Search
bmc4 [Sat, 22 May 2021 05:47:23 +0000 (02:47 -0300)]
Tuning Search

This patch tunes constant in search.cpp

STC:
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 30648 W: 2580 L: 2410 D: 25658
Ptnml(0-2): 80, 1969, 11093, 2065, 117
https://tests.stockfishchess.org/tests/view/60a71d3cce8ea25a3ef03fae

LTC:
LLR: 2.95 (-2.94,2.94) <0.50,3.50>
Total: 52896 W: 1776 L: 1617 D: 49503
Ptnml(0-2): 13, 1462, 23347, 1605, 21
https://tests.stockfishchess.org/tests/view/60a794ddce8ea25a3ef0400a

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

Bench: 4004731

2 years agoSimplify reduction for consecutive fails
bmc4 [Sat, 22 May 2021 05:41:52 +0000 (02:41 -0300)]
Simplify reduction for consecutive fails

Revert the heuristic introduced in #3184, by which we reduced more
the late sons of the root position after consecutive fail highs.

---
Before new net architecture:

STC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 226336 W: 20373 L: 20500 D: 185463
Ptnml(0-2): 755, 16087, 79595, 15992, 739
https://tests.stockfishchess.org/tests/view/609dec205085663412d08e9d

LTC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 67432 W: 2411 L: 2375 D: 62646
Ptnml(0-2): 33, 1944, 29714, 2004, 21
https://tests.stockfishchess.org/tests/view/609ee30f5085663412d08fc3

---
After new net architecture:

STC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 141752 W: 11591 L: 11617 D: 118544
Ptnml(0-2): 387, 9231, 51674, 9189, 395
https://tests.stockfishchess.org/tests/view/60a4320ace8ea25a3ef03cfd

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 294072 W: 9825 L: 9950 D: 274297
Ptnml(0-2): 121, 8610, 129681, 8521, 103
https://tests.stockfishchess.org/tests/view/60a51b5ece8ea25a3ef03dcd
---

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

Bench: 3752892

2 years agoUpdate default net to nn-7756374aaed3.nnue
Joost VandeVondele [Sat, 22 May 2021 05:00:53 +0000 (07:00 +0200)]
Update default net to nn-7756374aaed3.nnue

trained with pytorch using the master branch and recommended settings,
same data set as previously used:

python train.py ../../all_d9_fishd9_d8_d10_shuffle.binpack ../../all_d9_fishd9_d8_d10_shuffle.binpack \
        --gpus 1 --threads 2 --num-workers 2 --batch-size 16384 --progress_bar_refresh_rate 300 \
        --smart-fen-skipping --random-fen-skipping 3 --features=HalfKAv2^   --lambda=1.0 \
        --max_epochs=400 --seed $RANDOM --default_root_dir exp/run_8

passed STC:
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 21424 W: 2078 L: 1907 D: 17439
Ptnml(0-2): 80, 1512, 7385, 1627, 108
https://tests.stockfishchess.org/tests/view/60a6c749ce8ea25a3ef03f4d

passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,3.50>
Total: 67912 W: 2851 L: 2648 D: 62413
Ptnml(0-2): 40, 2348, 28984, 2537, 47
https://tests.stockfishchess.org/tests/view/60a722ecce8ea25a3ef03fb9

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

Bench: 3779522

2 years agoCompact position structures
Guy Vreuls [Fri, 21 May 2021 18:22:29 +0000 (20:22 +0200)]
Compact position structures

Reorder the structures data members in position.h to reduce padding.

Passed STC:
https://tests.stockfishchess.org/tests/view/60a8011fce8ea25a3ef04069
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 14120 W: 1214 L: 1067 D: 11839
Ptnml(0-2): 26, 857, 5161, 976, 40

---

Also tested for speed locally by Joost:

Result of  50 runs
==================
base (./stockfish.master       ) =    2254919  +/- 4439
test (./stockfish.patch        ) =    2274003  +/- 5278
diff                             =     +19084  +/- 6386
==================
speedup        = +0.0085
P(speedup > 0) =  1.0000

---

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

No functional change.

2 years agoRemove Tempo
Stéphane Nicolet [Tue, 18 May 2021 23:24:51 +0000 (01:24 +0200)]
Remove Tempo

The Tempo variable was introduced 10 years ago in our search because the
classical evaluation function was antisymmetrical in White and Black by design
to gain speed:

    Eval(White to play) = -Eval(Black to play)

Nowadays our neural networks know which side is to play in a position when
they evaluate a position and are trained on real games, so the neural network
encodes the advantage of moving as an output of search. This patch shows that
the Tempo variable is not necessary anymore.

STC:
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 33512 W: 2805 L: 2709 D: 27998
Ptnml(0-2): 80, 2209, 12095, 2279, 93
https://tests.stockfishchess.org/tests/view/60a44ceace8ea25a3ef03d30

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 53920 W: 1807 L: 1760 D: 50353
Ptnml(0-2): 16, 1617, 23650, 1658, 19
https://tests.stockfishchess.org/tests/view/60a477f0ce8ea25a3ef03d49

We also tried a match (20000 games) at STC using purely classical, result was neutral:
https://tests.stockfishchess.org/tests/view/60a4eebcce8ea25a3ef03db5

Note: there are two locations left in search.cpp where we assume antisymmetry
of evaluation (in relation with a speed optimization for null moves in lines
770 and 1439), but as the values are just used for heuristic pruning this
approximation should not hurt too much because the order of magnitude is still
true most of the time.

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

Bench: 4015864

2 years agoSimplify usage of LMR for captures
Vizvezdenec [Wed, 19 May 2021 17:57:04 +0000 (20:57 +0300)]
Simplify usage of LMR for captures

This patch simplifies a lot of "enablers" for LMR when move is a capture or promotion.
After it we will have only 2 conditions - if node is a cutNode
or if it's an allNode that was not in PV,
so all captures or promotions wouldn't go thru LMR at any PVnodes.

passed STC
https://tests.stockfishchess.org/tests/view/60a40117ce8ea25a3ef03ca7
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 58976 W: 4875 L: 4807 D: 49294
Ptnml(0-2): 176, 3897, 21270, 3973, 172

passed LTC
https://tests.stockfishchess.org/tests/view/60a43ff8ce8ea25a3ef03d18
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 65272 W: 2203 L: 2165 D: 60904
Ptnml(0-2): 28, 1936, 28668, 1978, 26

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

bench 4110764

2 years agoUse if instead of goto
Prokop Randáček [Wed, 12 May 2021 18:15:21 +0000 (20:15 +0200)]
Use if instead of goto

This PR inverts the if and removes goto in the generate_all function.

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

No functional change

2 years agoUse packed 32-bit MMX operations for updating the PSQT accumulator
Fanael Linithien [Tue, 18 May 2021 17:17:59 +0000 (19:17 +0200)]
Use packed 32-bit MMX operations for updating the PSQT accumulator

This improves the speed of NNUE by a bit on old hardware that code path
is intended for, like a Pentium III 1.13 GHz:

10 repeats of "./stockfish bench 16 1 13 default depth NNUE":

Before:
54 642 504 897 cycles (± 0.12%)
62 301 937 829 instructions (± 0.03%)

After:
54 320 821 928 cycles (± 0.13%)
62 084 742 699 instructions (± 0.02%)

Speed of go depth 20 from startpos:

Before: 53103 nps
After: 53856 nps

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

No functional change.

2 years agoUse Markdown syntax in the readme
Yohaan Seth Nathan [Tue, 18 May 2021 18:52:59 +0000 (00:22 +0530)]
Use Markdown syntax in the readme

provide direct links to the mentioned files.

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

No Functional Change

2 years agoDo more continuation history based pruning
Vizvezdenec [Tue, 18 May 2021 07:02:20 +0000 (10:02 +0300)]
Do more continuation history based pruning

This patch increases lmrDepth threshold for continuation history based pruning in search.
This part of code for a long time was known to be really TC sensitive - decreasing
this threshold easily passed lower time controls but failed badly at LTC,
on the other hand it increase was part of a tuning that resulted
in being negative at STC but was +12 elo at 180+1.8.

After recent simplification of special conditions that sometimes
increase it from 4 to 5 it was logical to overall test at longer
time controls if 5 is better than 4 with deeper searches.

reduces strenght on STC
https://tests.stockfishchess.org/tests/view/60a3a8bbce8ea25a3ef03c74
ELO: -2.57 +-2.0 (95%) LOS: 0.6%
Total: 20000 W: 1820 L: 1968 D: 16212
Ptnml(0-2): 68, 1582, 6836, 1458, 56

Passed LTC with STC bounds
https://tests.stockfishchess.org/tests/view/60a027395085663412d090ce
LLR: 2.93 (-2.94,2.94) <-0.50,2.50>
Total: 175256 W: 6774 L: 6548 D: 161934
Ptnml(0-2): 91, 5808, 75604, 6034, 91

Passed VLTC with LTC bounds
https://tests.stockfishchess.org/tests/view/60a2bccce229097940a037a7
LLR: 2.96 (-2.94,2.94) <0.50,3.50>
Total: 65736 W: 1224 L: 1092 D: 63420
Ptnml(0-2): 5, 1012, 30706, 1136, 9

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

bench 3689330

2 years agoNew NNUE architecture and net
Tomasz Sobczyk [Tue, 18 May 2021 15:36:26 +0000 (17:36 +0200)]
New NNUE architecture and net

Introduces a new NNUE network architecture and associated network parameters,
as obtained by a new pytorch trainer.

The network is already very strong at short TC, without regression at longer TC,
and has potential for further improvements.

https://tests.stockfishchess.org/tests/view/60a159c65085663412d0921d
TC: 10s+0.1s, 1 thread
ELO: 21.74 +-3.4 (95%) LOS: 100.0%
Total: 10000 W: 1559 L: 934 D: 7507
Ptnml(0-2): 38, 701, 2972, 1176, 113

https://tests.stockfishchess.org/tests/view/60a187005085663412d0925b
TC: 60s+0.6s, 1 thread
ELO: 5.85 +-1.7 (95%) LOS: 100.0%
Total: 20000 W: 1381 L: 1044 D: 17575
Ptnml(0-2): 27, 885, 7864, 1172, 52

https://tests.stockfishchess.org/tests/view/60a2beede229097940a03806
TC: 20s+0.2s, 8 threads
LLR: 2.93 (-2.94,2.94) <0.50,3.50>
Total: 34272 W: 1610 L: 1452 D: 31210
Ptnml(0-2): 30, 1285, 14350, 1439, 32

https://tests.stockfishchess.org/tests/view/60a2d687e229097940a03c72
TC: 60s+0.6s, 8 threads
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 45544 W: 1262 L: 1214 D: 43068
Ptnml(0-2): 12, 1129, 20442, 1177, 12

The network has been trained (by vondele) using the https://github.com/glinscott/nnue-pytorch/ trainer (started by glinscott),
specifically the branch https://github.com/Sopel97/nnue-pytorch/tree/experiment_56.
The data used are in 64 billion positions (193GB total) generated and scored with the current master net
d8: https://drive.google.com/file/d/1hOOYSDKgOOp38ZmD0N4DV82TOLHzjUiF/view?usp=sharing
d9: https://drive.google.com/file/d/1VlhnHL8f-20AXhGkILujnNXHwy9T-MQw/view?usp=sharing
d10: https://drive.google.com/file/d/1ZC5upzBYMmMj1gMYCkt6rCxQG0GnO3Kk/view?usp=sharing
fishtest_d9: https://drive.google.com/file/d/1GQHt0oNgKaHazwJFTRbXhlCN3FbUedFq/view?usp=sharing

This network also contains a few architectural changes with respect to the current master:

    Size changed from 256x2-32-32-1 to 512x2-16-32-1
        ~15-20% slower
        ~2x larger
        adds a special path for 16 valued ClippedReLU
        fixes affine transform code for 16 inputs/outputs, buy using InputDimensions instead of PaddedInputDimensions
            this is safe now because the inputs are processed in groups of 4 in the current affine transform code
    The feature set changed from HalfKP to HalfKAv2
        Includes information about the kings like HalfKA
        Packs king features better, resulting in 8% size reduction compared to HalfKA
    The board is flipped for the black's perspective, instead of rotated like in the current master
    PSQT values for each feature
        the feature transformer now outputs a part that is fowarded directly to the output and allows learning piece values more directly than the previous network architecture. The effect is visible for high imbalance positions, where the current master network outputs evaluations skewed towards zero.
        8 PSQT values per feature, chosen based on (popcount(pos.pieces()) - 1) / 4
        initialized to classical material values on the start of the training
    8 subnetworks (512x2->16->32->1), chosen based on (popcount(pos.pieces()) - 1) / 4
        only one subnetwork is evaluated for any position, no or marginal speed loss

A diagram of the network is available: https://user-images.githubusercontent.com/8037982/118656988-553a1700-b7eb-11eb-82ef-56a11cbebbf2.png
A more complete description: https://github.com/glinscott/nnue-pytorch/blob/master/docs/nnue.md

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

Bench: 3806488

2 years agoSmall clean-ups
Stéphane Nicolet [Mon, 17 May 2021 07:13:34 +0000 (09:13 +0200)]
Small clean-ups

- Comment for Countemove pruning -> Continuation history
- Fix comment in input_slice.h
- Shorter lines in Makefile
- Comment for scale factor
- Fix comment for pinners in see_ge()
- Change Thread.id() signature to size_t
- Trailing space in reprosearch.sh
- Add Douglas Matos Gomes to the AUTHORS file
- Introduce comment for undo_null_move()
- Use Stockfish coding style for export_net()
- Change date in AUTHORS file

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

No functional change

2 years agoSimplification for countermoves based pruning
Vizvezdenec [Fri, 14 May 2021 21:55:45 +0000 (00:55 +0300)]
Simplification for countermoves based pruning

Simplify away two extra conditions in countermoves based pruning.
These conditions (both of them) were introduced quite a long time ago
via speculative LTCs and seem to no longer bring any benefit.

passed STC
https://tests.stockfishchess.org/tests/view/609e81f35085663412d08f31
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 28488 W: 2487 L: 2382 D: 23619
Ptnml(0-2): 87, 1919, 10123, 2032, 83

passed LTC
https://tests.stockfishchess.org/tests/view/609e9c085085663412d08f59
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 33176 W: 1219 L: 1155 D: 30802
Ptnml(0-2): 13, 1036, 14423, 1106, 10

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

Bench: 4749514

2 years agoSimplify LMR rules for statScore
bmc4 [Fri, 14 May 2021 02:47:41 +0000 (23:47 -0300)]
Simplify LMR rules for statScore

We simplify two parts of LMR which seem not to bring strength anymore.

---

Individual Tests:
https://tests.stockfishchess.org/tests/view/609d1cc15085663412d0856a
https://tests.stockfishchess.org/tests/view/609cb0cc7746e3dc74ffae8d
https://tests.stockfishchess.org/tests/view/609d1c9f5085663412d08568

---

LTC:
LLR: 2.97 (-2.94,2.94) <-2.50,0.50>
Total: 84184 W: 3093 L: 3066 D: 78025
Ptnml(0-2): 47, 2755, 36458, 2788, 44
https://tests.stockfishchess.org/tests/view/609d84615085663412d08e2f

---

While at it, we also update the Elo estimate of the previous rule in LMR, see:
https://tests.stockfishchess.org/tests/view/609a933c3a33eb67a844f7ca
https://tests.stockfishchess.org/tests/view/609a959c3a33eb67a844f7d5
https://tests.stockfishchess.org/tests/view/609afff73a33eb67a844f870

---

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

Bench: 4156523

2 years agoRemove early return in Probcut code
bmc4 [Thu, 13 May 2021 14:12:56 +0000 (11:12 -0300)]
Remove early return in Probcut code

We simplify away early return in ProbCut, as it seems not to bring any strength anymore.

STC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 42632 W: 3705 L: 3617 D: 35310
Ptnml(0-2): 123, 2947, 15110, 2991, 145
https://tests.stockfishchess.org/tests/view/609c49da7746e3dc74ffae02

LTC:
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 35384 W: 1314 L: 1251 D: 32819
Ptnml(0-2): 11, 1130, 15355, 1177, 19
https://tests.stockfishchess.org/tests/view/609c71467746e3dc74ffae47

---

While at it, we also update the Elo estimate of ProbCut
(see https://tests.stockfishchess.org/tests/view/609bfb597746e3dc74ffabe3).

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

bench: 3764662

2 years agoRemove BoolConditions from tuning code
Unai Corzo [Fri, 14 May 2021 15:35:32 +0000 (17:35 +0200)]
Remove BoolConditions from tuning code

Remove BoolConditions from tuning code, as the feature does not work
and the code has not be touched in years.

No functional change

2 years agoSimplify LMR rule for non-checking captures
bmc4 [Wed, 12 May 2021 12:38:26 +0000 (09:38 -0300)]
Simplify LMR rule for non-checking captures

We simplify away the complicated rule in LMR for "non-checking captures
likely to be bad", as it seems not to bring any strength anymore.

STC:
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 55256 W: 4972 L: 4897 D: 45387
Ptnml(0-2): 177, 3976, 19234, 4077, 164
https://tests.stockfishchess.org/tests/view/609adf3b3a33eb67a844f842

LTC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 10344 W: 437 L: 353 D: 9554
Ptnml(0-2): 1, 322, 4449, 392, 8
https://tests.stockfishchess.org/tests/view/609b3dfa3a33eb67a844f88e

--

While at it, we also update the Elo estimate of the previous rule in LMR
(see https://tests.stockfishchess.org/tests/view/609af2a63a33eb67a844f867).

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

Bench: 3840688

2 years agoE2K: added support for MCST Elbrus 2000 CPU architecture
EntityFX [Mon, 12 Apr 2021 10:42:35 +0000 (13:42 +0300)]
E2K: added support for MCST Elbrus 2000 CPU architecture

e2k (Elbrus 2000) - this is a VLIW/EPIC architecture,
the like Intel Itanium (IA-64) architecture.
The architecture has half native / half software support
for most Intel/AMD SIMD (e.g. MMX/SSE/SSE2/SSE3/SSSE3/SSE4.1/SSE4.2/AES/AVX/AVX2 & 3DNow!/SSE4a/XOP/FMA4) via intrinsics.

https://en.wikipedia.org/wiki/Elbrus_2000

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

No functional change

2 years agoRemove coordination between searching threads
bmc4 [Sun, 9 May 2021 19:33:41 +0000 (16:33 -0300)]
Remove coordination between searching threads

In summary, this revert #2204, as it seems not to bring any strength anymore, so it's no long needed.

STC (5+0.05 @ 8 threads):
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 105728 W: 6406 L: 6393 D: 92929
Ptnml(0-2): 154, 5479, 41599, 5464, 168
https://tests.stockfishchess.org/tests/view/6096994095e7f1852abd3154

LTC (20+0.2 @ 8 threads):
LLR: 2.96 (-2.94,2.94) <-2.50,0.50>
Total: 26336 W: 774 L: 712 D: 24850
Ptnml(0-2): 9, 641, 11810, 695, 13
https://tests.stockfishchess.org/tests/view/6097c62995e7f1852abd31e8

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

No functional change.

2 years agoSimplify LMR
bmc4 [Tue, 11 May 2021 14:04:02 +0000 (11:04 -0300)]
Simplify LMR

as it seems not to bring any strength and thus is no longer needed.

Tests for updating elo estimates:
https://tests.stockfishchess.org/tests/view/6099ff123a33eb67a844f789
https://tests.stockfishchess.org/tests/view/60953e6695e7f1852abd305b

Individual simplification tests:
https://tests.stockfishchess.org/tests/view/6098cfc73a33eb67a844f6a1
https://tests.stockfishchess.org/tests/view/6095539495e7f1852abd308b

LTC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 96984 W: 3624 L: 3608 D: 89752
Ptnml(0-2): 45, 3222, 41939, 3244, 42
https://tests.stockfishchess.org/tests/view/6099921a3a33eb67a844f74f

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

bench: 3836428

2 years agoExporting the currently loaded network file
Tomasz Sobczyk [Fri, 7 May 2021 10:24:12 +0000 (12:24 +0200)]
Exporting the currently loaded network file

This PR adds an ability to export any currently loaded network.
The export_net command now takes an optional filename parameter.
If the loaded net is not the embedded net the filename parameter is required.

Two changes were required to support this:

* the "architecture" string, which is really just a some kind of description in the net, is now saved into netDescription on load and correctly saved on export.
* the AffineTransform scrambles weights for some architectures and sparsifies them, such that retrieving the index is hard. This is solved by having a temporary scrambled<->unscrambled index lookup table when loading the network, and the actual index is saved for each individual weight that makes it to canSaturate16. This increases the size of the canSaturate16 entries by 6 bytes.

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

No functional change

2 years agoCleanup of likelyFailLow logic
Vizvezdenec [Wed, 5 May 2021 16:03:20 +0000 (19:03 +0300)]
Cleanup of likelyFailLow logic

This patch broadens and simplifies definition of PvNode that is likely to fail low.
New definition can be described as following "If node was already researched
at depth >= current depth and failed low there" which is more logical than the
previous version and takes less space + allows to not recompute it every time during move loop.

Passed simplification STC
https://tests.stockfishchess.org/tests/view/609148bf95e7f1852abd2e82
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 20128 W: 1865 L: 1751 D: 16512
Ptnml(0-2): 63, 1334, 7165, 1430, 72

Passed simplification LTC
https://tests.stockfishchess.org/tests/view/6091691295e7f1852abd2e8b
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 95128 W: 3498 L: 3481 D: 88149
Ptnml(0-2): 41, 2956, 41549, 2981, 37

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

Bench: 3933037

2 years agoAdd an UCI level command "export_net".
Tomasz Sobczyk [Sun, 2 May 2021 16:50:09 +0000 (18:50 +0200)]
Add an UCI level command "export_net".

This command writes the embedded net to the file `EvalFileDefaultName`.
If there is no embedded net the command does nothing.

fixes #3453

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

No functional change

2 years agoSimplify check extension
Unai Corzo [Sat, 1 May 2021 08:18:57 +0000 (10:18 +0200)]
Simplify check extension

Simplify check extension, as it seems not to bring any strength and thus is no longer needed.

STC https://tests.stockfishchess.org/tests/view/608c18e995e7f1852abd2b81
LLR: 2.94 (-2.94,2.94) <-2.50,0.50>
Total: 54544 W: 4891 L: 4815 D: 44838
Ptnml(0-2): 186, 3889, 19081, 3895, 221

LTC https://tests.stockfishchess.org/tests/view/608c6ab195e7f1852abd2bc6
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 51008 W: 1845 L: 1794 D: 47369
Ptnml(0-2): 31, 1591, 22206, 1648, 28

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

bench: 3993071

2 years agoAdd some more information on the UCI protocol
Joost VandeVondele [Thu, 29 Apr 2021 06:18:37 +0000 (08:18 +0200)]
Add some more information on the UCI protocol

Improve README.md: provide a link to the protocol,
and document some non-standard options.

fixes https://github.com/official-stockfish/Stockfish/issues/3446

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

No functional change

2 years agoChange tempo with time and threads
xoto10 [Sat, 24 Apr 2021 13:46:01 +0000 (14:46 +0100)]
Change tempo with time and threads

Introduce variable tempo for nnue depending on logarithm of estimated
strength, where strength is the product of time and number of threads.

The original idea here was that NNUE is best with a slightly different
tempo value to classical, since its style of play is slightly different.
It turns out that the best tempo for NNUE varies with strength of play,
so a formula is used which gives about 19 for STC and 24 for LTC under
current fishtest settings.

STC 10+0.1:
LLR: 2.94 (-2.94,2.94) {-0.20,1.10}
Total: 120816 W: 11155 L: 10861 D: 98800
Ptnml(0-2): 406, 8728, 41933, 8848, 493
https://tests.stockfishchess.org/tests/view/60735b3a8141753378960534

LTC 60+0.6:
LLR: 2.94 (-2.94,2.94) {0.20,0.90}
Total: 35688 W: 1392 L: 1234 D: 33062
Ptnml(0-2): 23, 1079, 15473, 1255, 14
https://tests.stockfishchess.org/tests/view/6073ffbc814175337896057f

Passed non-regression SMP test at LTC 20+0.2 (8 threads):
LLR: 2.95 (-2.94,2.94) {-0.70,0.20}
Total: 11008 W: 317 L: 267 D: 10424
Ptnml(0-2): 2, 245, 4962, 291, 4
https://tests.stockfishchess.org/tests/view/60749ea881417533789605a4

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

Bench 4075325

2 years agoSimplify pawn moves generator
bmc4 [Tue, 27 Apr 2021 22:59:46 +0000 (19:59 -0300)]
Simplify pawn moves generator

This patch simplifies QUIET_CHECKS pawn move generator by merging discovery check
move generator with direct check move generator. It also simplifies emptySquares
instantiation. In addition, I added a comment in generate_moves() to clarify Check
branches.

STC:
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 112648 W: 9952 L: 9945 D: 92751
Ptnml(0-2): 369, 7682, 40195, 7729, 349
https://tests.stockfishchess.org/tests/view/6088226895e7f1852abd2978

LTC:
LLR: 2.93 (-2.94,2.94) <-2.50,0.50>
Total: 74656 W: 2797 L: 2765 D: 69094
Ptnml(0-2): 38, 2328, 32554, 2380, 28
https://tests.stockfishchess.org/tests/view/60884e5095e7f1852abd2994

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

No functional change

2 years agoMore extensions if SE search is very low.
lonfom169 [Sun, 25 Apr 2021 00:37:47 +0000 (21:37 -0300)]
More extensions if SE search is very low.

More extensions for non-PV nodes if value from singular extension search is significantly below singularBeta.

Passed STC:
LLR: 2.97 (-2.94,2.94) <-0.50,2.50>
Total: 25064 W: 2334 L: 2162 D: 20568
Ptnml(0-2): 82, 1720, 8768, 1868, 94
https://tests.stockfishchess.org/tests/view/6084ba7995e7f1852abd27e3

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,3.50>
Total: 67136 W: 2644 L: 2450 D: 62042
Ptnml(0-2): 46, 2134, 28990, 2376, 22
https://tests.stockfishchess.org/tests/view/6084d79195e7f1852abd27ee

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

Bench: 4075325

2 years agoThread based reduction tweak.
Stefan Geschwentner [Sun, 25 Apr 2021 05:09:35 +0000 (07:09 +0200)]
Thread based reduction tweak.

For PV nodes at the first two plies no reductions are done for each fourth thread.

STC (8 threads):
LLR: 2.94 (-2.94,2.94) <-0.50,2.50>
Total: 53992 W: 3334 L: 3167 D: 47491
Ptnml(0-2): 64, 2713, 21285, 2860, 74
https://tests.stockfishchess.org/tests/view/6083b2d695e7f1852abd277a

LTC (8 threads):
LLR: 2.93 (-2.94,2.94) <0.50,3.50>
Total: 64888 W: 1888 L: 1725 D: 61275
Ptnml(0-2): 14, 1556, 29146, 1709, 19
https://tests.stockfishchess.org/tests/view/6084249595e7f1852abd2795

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

No functional change (for one thread)

2 years agoCleanup and simplify NNUE code.
Tomasz Sobczyk [Sat, 24 Apr 2021 13:08:11 +0000 (15:08 +0200)]
Cleanup and simplify NNUE code.

A lot of optimizations happend since the NNUE was introduced
and since then some parts of the code were left unused. This
got to the point where asserts were have to be made just to
let people know that modifying something will not have any
effects or may even break everything due to the assumptions
being made. Removing these parts removes those inexisting
"false dependencies". Additionally:

 * append_changed_indices now takes the king pos and stateinfo
   explicitly, no more misleading pos parameter
 * IndexList is removed in favor of a generic ValueList.
   Feature transformer just instantiates the type it needs.
 * The update cost and refresh requirement is deferred to the
   feature set once again, but now doesn't go through the whole
   FeatureSet machinery and just calls HalfKP directly.
 * accumulator no longer has a singular dimension.
 * The PS constants and the PieceSquareIndex array are made local
   to the HalfKP feature set because they are specific to it and
   DO differ for other feature sets.
 * A few names are changed to more descriptive

Passed STC non-regression:
https://tests.stockfishchess.org/tests/view/608421dd95e7f1852abd2790
LLR: 2.95 (-2.94,2.94) <-2.50,0.50>
Total: 180008 W: 16186 L: 16258 D: 147564
Ptnml(0-2): 587, 12593, 63725, 12503, 596

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

No functional change

2 years agoMerge all move generators
bmc4 [Thu, 22 Apr 2021 17:07:37 +0000 (14:07 -0300)]
Merge all move generators

Merging `generate<EVASIONS>` and `generate<QUIET_CHECKS>` into `generate_all()`.

verified to yield correct perft results, even though bench changes due to different order of generated moves.

No regresion playing games:

passed STC:
LLR: 2.94 (-2.94,2.94) {-1.00,0.20}
Total: 161800 W: 14585 L: 14624 D: 132591
Ptnml(0-2): 577, 11681, 56451, 11586, 605
https://tests.stockfishchess.org/tests/view/606532732b2df919fd5f026d

passed LTC:
LLR: 2.98 (-2.94,2.94) {-0.70,0.20}
Total: 188504 W: 6906 L: 6961 D: 174637
Ptnml(0-2): 87, 6272, 81610, 6175, 108
https://tests.stockfishchess.org/tests/view/6065b0772b2df919fd5f02ae

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

Bench: 4536129

2 years agoUnify naming convention of the NNUE code
Tomasz Sobczyk [Mon, 19 Apr 2021 17:50:19 +0000 (19:50 +0200)]
Unify naming convention of the NNUE code

matches the rest of the stockfish code base

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

No functional change

3 years agoUse classical eval for Bishop vs Pawns
dsmsgms [Mon, 12 Apr 2021 15:06:22 +0000 (12:06 -0300)]
Use classical eval for Bishop vs Pawns

NNUE evaluation is incapable of recognizing trivially drawn bishop endgames
(the wrong-colored rook pawn), which are in fact ubiquitous and stock standard
in chess analysis. Switching off NNUE evaluation in KBPs vs KPs endgames is
a measure that stops Stockfish from trading down to a drawn version of these
endings when we presumably have advantage. The patch is able to edge over master
in endgame positions.

Patch tested for Elo gain with the "endgame.epd" book, and verified for
non-regression with our usual book (see the pull request for details).

STC:
LLR: 2.93 (-2.94,2.94) {-0.20,1.10}
Total: 33232 W: 6655 L: 6497 D: 20080
Ptnml(0-2): 4, 2342, 11769, 2494, 7
https://tests.stockfishchess.org/tests/view/6074a52981417533789605b8

LTC:
LLR: 2.93 (-2.94,2.94) {0.20,0.90}
Total: 159056 W: 29799 L: 29378 D: 99879
Ptnml(0-2): 7, 9004, 61085, 9425, 7
https://tests.stockfishchess.org/tests/view/6074c39a81417533789605ca

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

Bench: 4503918

blah

3 years agoDocumentation patch: AppendChangedIndices
Tomasz Sobczyk [Tue, 13 Apr 2021 18:02:28 +0000 (20:02 +0200)]
Documentation patch: AppendChangedIndices

Clarify the assumptions on the position passed to the AppendChangedIndices().

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

No functional change

3 years agoSimplification: last capture extension
Vizvezdenec [Wed, 14 Apr 2021 18:25:18 +0000 (21:25 +0300)]
Simplification: last capture extension

The code for last capture extension can be removed in current master.

Passed STC
LLR: 2.95 (-2.94,2.94) {-1.00,0.20}
Total: 85024 W: 7754 L: 7707 D: 69563
Ptnml(0-2): 293, 5991, 29914, 6004, 310
https://tests.stockfishchess.org/tests/view/607690f1814175337896068f

Passed LTC
LLR: 2.96 (-2.94,2.94) {-0.70,0.20}
Total: 39880 W: 1503 L: 1453 D: 36924
Ptnml(0-2): 17, 1281, 17293, 1333, 16
https://tests.stockfishchess.org/tests/view/6076ccbe814175337896069e

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

Bench: 4202264

3 years agoRevert previous patch
Stéphane Nicolet [Thu, 15 Apr 2021 09:18:38 +0000 (11:18 +0200)]
Revert previous patch

Revert the previous patch about move generation, as it unexpectedly
changed the bench. Better to take the time to understand the issue.

Bench: 4191632

3 years agoMerge all move generators
bmc4 [Fri, 2 Apr 2021 12:30:14 +0000 (09:30 -0300)]
Merge all move generators

Merging `generate<EVASIONS>` and `generate<QUIET_CHECKS>` into `generate_all()`.

STC:
LLR: 2.94 (-2.94,2.94) {-1.00,0.20}
Total: 161800 W: 14585 L: 14624 D: 132591
Ptnml(0-2): 577, 11681, 56451, 11586, 605
https://tests.stockfishchess.org/tests/view/606532732b2df919fd5f026d

LTC:
LLR: 2.98 (-2.94,2.94) {-0.70,0.20}
Total: 188504 W: 6906 L: 6961 D: 174637
Ptnml(0-2): 87, 6272, 81610, 6175, 108
https://tests.stockfishchess.org/tests/view/6065b0772b2df919fd5f02ae

------------

Verified for correctness of `EVASIONS` by running perft:
```
./stockfish b3nch 16 1 6 default perft          (replace 3 by e in b3nch)
Nodes searched  : 71608931810
```

Also tested for correctness on Chess960 with a similar code shown here:
https://github.com/official-stockfish/Stockfish/pull/3418#issuecomment-816630295

```
./stockfish b3nch 16 1 6 fischer.txt perft
Nodes searched  : 506736009395
```

------------

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

No functional change

3 years agoReplace distanceFromPv with a better logic
Vizvezdenec [Tue, 6 Apr 2021 13:51:05 +0000 (16:51 +0300)]
Replace distanceFromPv with a better logic

This patch removes the recently introduced distanceFromPv logic, and replaces
it with following logic: if reduction of moves with low movecount is really
negative, we search them deeper than the first move.

passed STC:
LLR: 2.95 (-2.94,2.94) {-0.20,1.10}
Total: 153008 W: 13913 L: 13579 D: 125516
Ptnml(0-2): 547, 10811, 53470, 11113, 563
https://tests.stockfishchess.org/tests/view/6069c9d02b2df919fd5f04d2

passed LTC:
LLR: 2.94 (-2.94,2.94) {0.20,0.90}
Total: 101920 W: 3964 L: 3699 D: 94257
Ptnml(0-2): 55, 3279, 44019, 3560, 47
https://tests.stockfishchess.org/tests/view/606a99fd2b2df919fd5f0532

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

Bench: 4191632

3 years agoKeep more pawns
Stéphane Nicolet [Sun, 4 Apr 2021 08:51:45 +0000 (10:51 +0200)]
Keep more pawns

This patch increases the weight of pawns in the scale factor applied
to the output of the NNUE evaluation. This has the effect that Stockfish
will try a little bit harder to keep more pawns in position where the
engine has the advantage, and exchange more pawns in bad positions.

STC:
LLR: 2.93 (-2.94,2.94) {-0.20,1.10}
Total: 42552 W: 3858 L: 3668 D: 35026
Ptnml(0-2): 152, 2956, 14876, 3134, 158
https://tests.stockfishchess.org/tests/view/606a06dd2b2df919fd5f0504

LTC:
LLR: 2.95 (-2.94,2.94) {0.20,0.90}
Total: 44328 W: 1703 L: 1531 D: 41094
Ptnml(0-2): 20, 1373, 19207, 1543, 21
https://tests.stockfishchess.org/tests/view/606aa4ec2b2df919fd5f053e

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

Bench: 4310076

3 years agoSmall clean-up
Stéphane Nicolet [Wed, 24 Mar 2021 20:55:49 +0000 (21:55 +0100)]
Small clean-up

Bench: 4321677

3 years agoSimplify King Evasion
bmc4 [Tue, 30 Mar 2021 03:42:45 +0000 (00:42 -0300)]
Simplify King Evasion

Simplify away the removal of some illegal `KING`-evasion moves during move
generation. Verified for correctness by running perft on the following positions:

```
./stockfish
bench 16 1 6 default perft
Nodes searched: 71608931810

./stockfish
position fen 4rrk1/1p1nq3/p7/2p1P1pp/3P2bp/3Q1Bn1/PPPB4/1K2R1NR w - - 40 21
go perft 6
Nodes searched: 6136386434
```

Passed STC:
LLR: 2.94 (-2.94,2.94) {-1.00,0.20}
Total: 16072 W: 1473 L: 1349 D: 13250
Ptnml(0-2): 57, 1047, 5710, 1159, 63
https://tests.stockfishchess.org/tests/view/60629e7ef183b42957b423b1

Passed LTC:
LLR: 2.94 (-2.94,2.94) {-0.70,0.20}
Total: 59064 W: 2214 L: 2177 D: 54673
Ptnml(0-2): 26, 1944, 25556, 1979, 27
https://tests.stockfishchess.org/tests/view/6062dce4f183b42957b423de

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

No functional change

3 years agoSimplify and unify FRC cornered bishop.
mstembera [Thu, 25 Mar 2021 20:33:05 +0000 (13:33 -0700)]
Simplify and unify FRC cornered bishop.

tested locally as fishtest doesn't support FRC:

STC NNUE
9646 - 9647 - 20707 [0.500] 40000 -0.0 +/- 2.4, LOS: 49.7 %, DrawRatio: 51.8 %

STC classical
9678 - 9609 - 20713 [0.501] 40000 0.6 +/- 2.4, LOS: 69.0 %, DrawRatio: 51.8 %

and verified independently:

Score of master vs patch: 6463 - 6580 - 34957 [0.499] 48000

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

bench: 4321677

3 years agoAllow using Intel SDE for PGO builds.
Tomasz Sobczyk [Sat, 27 Feb 2021 10:52:18 +0000 (11:52 +0100)]
Allow using Intel SDE for PGO builds.

The software development emulator (SDE) allows to run binaries compiled
for architectures not supported by the actual CPU. This is useful to
do PGO builds for newer architectures. The SDE can currently be obtained from
https://software.intel.com/content/www/us/en/develop/articles/intel-software-development-emulator.html

This patch introduces a new optional makefile argument SDE_PATH.
If not empty it should contain the path to the sde executable

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

No functional change.

3 years agoSmall cleanups (march 2021)
Stéphane Nicolet [Fri, 19 Mar 2021 18:43:25 +0000 (19:43 +0100)]
Small cleanups (march 2021)

With help of @BM123499, @mstembera, @gvreuls, @noobpwnftw and @Fanael
Thanks!

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

No functional change

3 years agoUse reference instead of pointer for pop_lsb() signature
Guy Vreuls [Sat, 13 Mar 2021 16:40:07 +0000 (17:40 +0100)]
Use reference instead of pointer for pop_lsb() signature

This patch changes the pop_lsb() signature from Square pop_lsb(Bitboard*) to
Square pop_lsb(Bitboard&). This is more idomatic for C++ style signatures.

Passed a non-regression STC test:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 21280 W: 1928 L: 1847 D: 17505
Ptnml(0-2): 71, 1427, 7558, 1518, 66
https://tests.stockfishchess.org/tests/view/6053a1e22433018de7a38e2f

We have verified that the generated binary is identical on gcc-10.

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

No functional change.

3 years agoAdd a specific FRC correction from classical to NNUE
Vizvezdenec [Mon, 15 Mar 2021 18:05:01 +0000 (19:05 +0100)]
Add a specific FRC correction from classical to NNUE

our net currently is not trained on FRC games, and so doesn't know about the important pattern of a bishop that is cornered in FRC.
This patch introduces a term we have in the classical evaluation for this case, and adds it to the NNUE eval.

Since fishtest doesn't support FRC right now, the patch was tested locally at STC conditions,
starting from the book of FRC starting positions.

Score of master vs patch: 993 - 2226 - 6781  [0.438] 10000

Which corresponds to approximately 40 Elo

The patch passes non-regression testing for traditional chess (where it adds one branch).

passed STC:
https://tests.stockfishchess.org/tests/view/604fa2532433018de7a38b67
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 30560 W: 2701 L: 2636 D: 25223
Ptnml(0-2): 88, 2056, 10921, 2133, 82

passed STC also in an earlier version:
https://tests.stockfishchess.org/tests/view/604f61282433018de7a38b4d

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

No functional change

3 years agoChange definition of between_bb()
bmc4 [Mon, 15 Mar 2021 19:06:42 +0000 (16:06 -0300)]
Change definition of between_bb()

We remark that in current master, most of our use cases for between_bb() can be
optimized if the second parameter of the function is added to the segment. So we
change the definition of between_bb(s1, s2) such that it excludes s1 but includes s2.

We also use a precomputed array for between_bb() for another small speed gain
(see https://tests.stockfishchess.org/tests/view/604d09f72433018de7a389fb).

Passed STC:
LLR: 2.96 (-2.94,2.94) {-0.25,1.25}
Total: 18736 W: 1746 L: 1607 D: 15383
Ptnml(0-2): 61, 1226, 6644, 1387, 50
https://tests.stockfishchess.org/tests/view/60428c84ddcba5f0627bb6e4

Yellow LTC:
LTC:
LLR: -3.00 (-2.94,2.94) {0.25,1.25}
Total: 39144 W: 1431 L: 1413 D: 36300
Ptnml(0-2): 13, 1176, 17184, 1178, 21
https://tests.stockfishchess.org/tests/view/605128702433018de7a38ca1

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

---------

Verified for correctness by running perft on the following position:

./stockfish
position fen 4rrk1/1p1nq3/p7/2p1P1pp/3P2bp/3Q1Bn1/PPPB4/1K2R1NR w - - 40 21
go perft 6

Nodes searched: 6136386434

--------

No functional change

3 years agoRemove advanced_pawn_push()
Vizvezdenec [Thu, 11 Mar 2021 11:51:20 +0000 (14:51 +0300)]
Remove advanced_pawn_push()

Continuation of work by @topologist: we now do futility pruning and movecount
pruning in qsearch() for pawn pushes up to the 7th rank. So the condition to
avoid the pruning is if the move is a promotion or not. This allows to get rid
of the advanced_pawn_push() function in position.h alltogether.

Passed STC
https://tests.stockfishchess.org/tests/view/6048c5842433018de7a387e6
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 34424 W: 3081 L: 3015 D: 28328
Ptnml(0-2): 110, 2442, 12052, 2488, 120

Passed LTC
https://tests.stockfishchess.org/tests/view/6048f7d22433018de7a387f0
LLR: 2.94 (-2.94,2.94) {-0.75,0.25}
Total: 142024 W: 5170 L: 5202 D: 131652
Ptnml(0-2): 50, 4678, 61613, 4596, 75

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

Bench: 4339126

3 years agoSimplify move generation (2/2)
bmc4 [Tue, 16 Mar 2021 15:21:24 +0000 (12:21 -0300)]
Simplify move generation (2/2)

STC:
LLR: 2.97 (-2.94,2.94) {-1.25,0.25}
Total: 39352 W: 3551 L: 3493 D: 32308
Ptnml(0-2): 143, 2695, 13928, 2781, 129
https://tests.stockfishchess.org/tests/view/6050007a2433018de7a38bbb

LTC:
LLR: 2.96 (-2.94,2.94) {-0.75,0.25}
Total: 44944 W: 1629 L: 1596 D: 41719
Ptnml(0-2): 22, 1319, 19762, 1342, 27
https://tests.stockfishchess.org/tests/view/60500e892433018de7a38bc4

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

No functional change

3 years agoSimplify move generation (1/2)
bmc4 [Mon, 15 Mar 2021 22:52:45 +0000 (19:52 -0300)]
Simplify move generation (1/2)

STC:
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 29792 W: 2611 L: 2545 D: 24636
Ptnml(0-2): 94, 1982, 10659, 2086, 75
https://tests.stockfishchess.org/tests/view/604fe5b62433018de7a38ba8

LTC:
LLR: 2.92 (-2.94,2.94) {-0.75,0.25}
Total: 22040 W: 826 L: 777 D: 20437
Ptnml(0-2): 8, 646, 9664, 693, 9
https://tests.stockfishchess.org/tests/view/604fec892433018de7a38bac

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

No functional change

3 years agoIntroduce least_significant_square_bb()
bmc4 [Tue, 16 Mar 2021 19:51:31 +0000 (20:51 +0100)]
Introduce least_significant_square_bb()

Introducing least_significant_square_bb(). It is a function that returns a value equal
to square_bb(lsb(bb)), but it uses fewer instruction. It should speed up more on older
processors like armv7-a Clang.

Passed STC:
LLR: 2.93 (-2.94,2.94) {-0.25,1.25}
Total: 213200 W: 19171 L: 18753 D: 175276
Ptnml(0-2): 680, 14513, 75831, 14861, 715
https://tests.stockfishchess.org/tests/view/604bc7632433018de7a38982

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

No functional change

3 years agoChange advanced pawn push threshold
Topologist [Mon, 8 Mar 2021 18:46:41 +0000 (19:46 +0100)]
Change advanced pawn push threshold

A pawn push is now considered to be "advanced" if the relative destination
rank is > 6 (previously it was > 5). This affects the search heuristic.

Also remove an assert concerning en passant moves in qsearch().

STC:
LLR: 2.97 (-2.94,2.94) {-0.25,1.25}
Total: 46744 W: 4224 L: 4040 D: 38480
Ptnml(0-2): 165, 3206, 16451, 3380, 170
https://tests.stockfishchess.org/tests/view/604746082433018de7a3872e

LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.25}
Total: 107840 W: 4198 L: 3892 D: 99750
Ptnml(0-2): 58, 3472, 46557, 3772, 61
https://tests.stockfishchess.org/tests/view/60475eae2433018de7a38737

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

Bench: 4796780

3 years agoUse Bitboard over Square in movegen
bmc4 [Fri, 5 Mar 2021 11:57:43 +0000 (08:57 -0300)]
Use Bitboard over Square in movegen

It uses pos.checkers() on target when movegen is the type of EVASION.
It simplify the code. And it's also expected a slightly speed up,
because Bitboard is more direct when doing bitwise.

Passed STC:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 28176 W: 2506 L: 2437 D: 23233
Ptnml(0-2): 80, 1904, 10063, 1949, 92
https://tests.stockfishchess.org/tests/view/60421d18ddcba5f0627bb6a9

Passed LTC:
LLR: 2.93 (-2.94,2.94) {-0.75,0.25}
Total: 9704 W: 402 L: 341 D: 8961
Ptnml(0-2): 3, 279, 4230, 334, 6
https://tests.stockfishchess.org/tests/view/60422823ddcba5f0627bb6ae

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

No functional change

3 years agoDeal with commented lines in UCI input
mattginsberg [Sun, 28 Feb 2021 15:59:07 +0000 (07:59 -0800)]
Deal with commented lines in UCI input

commands starting with '#' as the first character will be ignored

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

No functional change

3 years agoDo not try to use large pages on 32 bit Windows.
noobpwnftw [Wed, 3 Mar 2021 14:30:23 +0000 (22:30 +0800)]
Do not try to use large pages on 32 bit Windows.

verified to work on windows XP.

fixes  #3379

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

No functional change.

3 years agoAdd Stockfish namespace.
Dieter Dobbelaere [Fri, 26 Feb 2021 09:02:13 +0000 (10:02 +0100)]
Add Stockfish namespace.

fixes #3350 and is a small cleanup that might make it easier to use SF
in separate projects, like a NNUE trainer or similar.

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

No functional change.

3 years agoClean functions returning by const values
Antoine Champion [Sat, 30 Jan 2021 08:50:04 +0000 (09:50 +0100)]
Clean functions returning by const values

The codebase contains multiple functions returning by const-value.
This patch is a small cleanup making those function returns
by value instead, removing the const specifier.

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

No functional change

3 years agoIntroduce DistanceFromPV
Stéphane Nicolet [Fri, 26 Feb 2021 09:13:37 +0000 (10:13 +0100)]
Introduce DistanceFromPV

We introduce a metric for each internal node in search, called DistanceFromPV.
This distance indicated how far the current node is from the principal variation.

We then use this distance to search the nodes which are close to the PV a little
deeper (up to 4 plies deeper than the PV): this improves the quality of the search
at these nodes and bring better updates for the PV during search.

STC:
LLR: 2.96 (-2.94,2.94) {-0.25,1.25}
Total: 54936 W: 5047 L: 4850 D: 45039
Ptnml(0-2): 183, 3907, 19075, 4136, 167
https://tests.stockfishchess.org/tests/view/6037b88e7f517a561bc4a392

LTC:
LLR: 2.95 (-2.94,2.94) {0.25,1.25}
Total: 49608 W: 1880 L: 1703 D: 46025
Ptnml(0-2): 22, 1514, 21555, 1691, 22
https://tests.stockfishchess.org/tests/view/6038271b7f517a561bc4a3cb

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

Bench: 5037279

3 years agoIntroduce ProbCut for check evasions
Vizvezdenec [Sat, 20 Feb 2021 21:48:08 +0000 (22:48 +0100)]
Introduce ProbCut for check evasions

The idea of this patch can be described as follows: if we are in check
and the transposition table move is a capture that returns a value
far above beta, we can assume that the opponent just blundered a piece
by giving check, and we return the transposition table value. This is
similar to the usual probCut logic for quiet moves, but with a different
threshold.

Passed STC
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 33440 W: 3056 L: 2891 D: 27493
Ptnml(0-2): 110, 2338, 11672, 2477, 123
https://tests.stockfishchess.org/tests/view/602cd1087f517a561bc49bda

Passed LTC
LLR: 2.98 (-2.94,2.94) {0.25,1.25}
Total: 10072 W: 401 L: 309 D: 9362
Ptnml(0-2): 2, 288, 4365, 378, 3
https://tests.stockfishchess.org/tests/view/602ceea57f517a561bc49bf0

The committed version has an additional fix to never return unproven wins
in the tablebase range or the mate range. This fix passed tests for non-
regression at STC and LTC:

STC:
LLR: 2.93 (-2.94,2.94) {-1.25,0.25}
Total: 26240 W: 2354 L: 2280 D: 21606
Ptnml(0-2): 85, 1763, 9372, 1793, 107
https://tests.stockfishchess.org/tests/view/602d86a87f517a561bc49c7a

LTC:
LLR: 2.95 (-2.94,2.94) {-0.75,0.25}
Total: 35304 W: 1299 L: 1256 D: 32749
Ptnml(0-2): 14, 1095, 15395, 1130, 18
https://tests.stockfishchess.org/tests/view/602d98d17f517a561bc49c83

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

Bench: 3830215

3 years agoTune search parameters (with Unai Corzo)
Vizvezdenec [Fri, 19 Feb 2021 07:32:12 +0000 (10:32 +0300)]
Tune search parameters (with Unai Corzo)

The values used in this patch are taken from a SPSA parameter tuning session
originated by Unai Corzo (@unaiic), but the final difference of his tune was
multiplied x2 by hand. Most of the credits should go to him :-)

STC:
https://tests.stockfishchess.org/tests/view/602f03d07f517a561bc49d40
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 67664 W: 6252 L: 6035 D: 55377
Ptnml(0-2): 256, 4799, 23527, 4972, 278

LTC:
https://tests.stockfishchess.org/tests/view/602f41697f517a561bc49d5a
LLR: 2.96 (-2.94,2.94) {0.25,1.25}
Total: 26256 W: 1034 L: 906 D: 24316
Ptnml(0-2): 10, 804, 11377, 922, 15

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

Bench: 3957653

3 years agoRestore development version
Stéphane Nicolet [Sat, 20 Feb 2021 21:19:14 +0000 (22:19 +0100)]
Restore development version

No functional change

3 years agoStockfish 13
Joost VandeVondele [Mon, 15 Feb 2021 12:58:51 +0000 (13:58 +0100)]
Stockfish 13

Official release version of Stockfish 13

Bench: 3766422

-----

It is our pleasure to release Stockfish 13 to chess fans worldwide.
As usual, downloads are freely available at

https://stockfishchess.org

The Stockfish project builds on a thriving community of enthusiasts
who contribute their expertise, time, and resources to build a free
and open-source chess engine that is robust, widely available, and
very strong. We would like to thank them all!

The good news first: from now on, our users can expect more frequent
high-quality releases of Stockfish! Sadly, this decision has been
triggered by the start of sales of the Fat Fritz 2 engine by ChessBase,
which is a copy of a very recent development version of Stockfish
with minor modifications. We refer to our statement on Fat Fritz 2[1]
and a community blog[2] for further information.

This version of Stockfish is significantly stronger than any of its
predecessors. Stockfish 13 outperforms Stockfish 12 by at least
35 Elo[3]. When playing against a one-year-old Stockfish, it wins 60
times more game pairs than it loses[4]. This release features an NNUE
network retrained on billions of positions, much faster network
evaluation code, and significantly improved search heuristics, as
well as additional evaluation tweaks. In the course of its development,
this version has won the superfinals of the TCEC Season 19 and
TCEC Season 20.

Going forward, the Leela Chess Zero and Stockfish teams will join
forces to demonstrate our commitment to open source chess engines and
training tools, and open data. We are convinced that our free and
open-source chess engines serve the chess community very well.

Stay safe and enjoy chess!

The Stockfish team
[1] https://blog.stockfishchess.org/post/643239805544792064/statement-on-fat-fritz-2
[2] https://lichess.org/blog/YCvy7xMAACIA8007/fat-fritz-2-is-a-rip-off
[3] https://tests.stockfishchess.org/tests/view/602bcccf7f517a561bc49b11
[4] https://tests.stockfishchess.org/tests/view/600fbb9c735dd7f0f0352d59

3 years agoUpdate README.md
Stéphane Nicolet [Tue, 16 Feb 2021 15:19:37 +0000 (16:19 +0100)]
Update README.md

• reorder some sections of the README file
• add reference to the AUTHORS file
• rename Syzygybases to Syzygy tablebases
• add pointer to the Discord channel
• more precise info about the GPLv3 licence

No functional change

3 years agoSmall trivial clean-ups, February 2021
Lolligerhans [Sun, 31 Jan 2021 12:46:05 +0000 (13:46 +0100)]
Small trivial clean-ups, February 2021

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

No functional change

3 years agoUpdate Top CPU Contributors
Stéphane Nicolet [Mon, 15 Feb 2021 22:58:03 +0000 (23:58 +0100)]
Update Top CPU Contributors

No functional change

3 years agoPV-Nodes likely to fail low
Vizvezdenec [Thu, 11 Feb 2021 07:45:16 +0000 (10:45 +0300)]
PV-Nodes likely to fail low

Do not decrease reduction at pv-nodes which are likely to fail low.

The idea of this patch can be described as following: during the search, if a node
on the principal variation was re-searched in non-pv search and this re-search got
a value which was much lower than alpha, then we can assume that this pv-node is
likely to fail low again, and we can reduce more aggressively at this node.

Passed STC
https://tests.stockfishchess.org/tests/view/6023a5fa7f517a561bc49638
LLR: 2.95 (-2.94,2.94) {-0.25,1.25}
Total: 70288 W: 6443 L: 6223 D: 57622
Ptnml(0-2): 239, 5022, 24436, 5174, 273

Passed LTC
https://tests.stockfishchess.org/tests/view/6023f2617f517a561bc49661
LLR: 2.94 (-2.94,2.94) {0.25,1.25}
Total: 105656 W: 4048 L: 3748 D: 97860
Ptnml(0-2): 67, 3312, 45761, 3630, 58

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

Bench: 3766422

3 years agoBetter code for hash table generation
mattginsberg [Thu, 11 Feb 2021 21:29:28 +0000 (22:29 +0100)]
Better code for hash table generation

This patch removes some magic numbers in TT bit management and introduce proper
constants in the code, to improve documentation and ease further modifications.

No function change

3 years agoEnable New Pass Manager for Clang.
Gian-Carlo Pascutto [Tue, 9 Feb 2021 16:38:58 +0000 (17:38 +0100)]
Enable New Pass Manager for Clang.

It's about 1% speedup for Stockfish.

Result of 100 runs
==================
base (...fish_clang12) =    1946851  +/- 3717
test (./stockfish    ) =    1967276  +/- 3408
diff                   =     +20425  +/- 2438

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

Thanks to David Major for making me aware of this part
of LLVM development.

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

No functional change

3 years agoDisable ThinLTO when using Clang.
Gian-Carlo Pascutto [Tue, 9 Feb 2021 13:05:35 +0000 (14:05 +0100)]
Disable ThinLTO when using Clang.

Benchmarking with current Clang 12 shows that
and ThinLTO is a pessimization, see issue #3341.

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

No functional change.

3 years agoFixes FreeBSD compilation when using Clang
Andy Pilate [Mon, 8 Feb 2021 21:02:42 +0000 (22:02 +0100)]
Fixes FreeBSD compilation when using Clang

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

No functional change

3 years agoSearch Parameters Tuning
bmc4 [Fri, 5 Feb 2021 00:50:22 +0000 (21:50 -0300)]
Search Parameters Tuning

A simple tuning on search.cpp.

based SPSA test:
https://tests.stockfishchess.org/tests/view/601f2a787f517a561bc493cd

passed STC:
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 117840 W: 10796 L: 10508 D: 96536
Ptnml(0-2): 422, 8381, 41041, 8639, 437
https://tests.stockfishchess.org/tests/view/602144c37f517a561bc494ae

passed LTC:
LLR: 2.96 (-2.94,2.94) {0.25,1.25}
Total: 25024 W: 972 L: 847 D: 23205
Ptnml(0-2): 7, 767, 10847, 876, 15
https://tests.stockfishchess.org/tests/view/602156877f517a561bc494be

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

Bench: 3974098

3 years agoPawns Tuning
FauziAkram [Sun, 7 Feb 2021 11:44:11 +0000 (13:44 +0200)]
Pawns Tuning

A simple tuning of Pawns parameters, and some PSQT changes.

Passed STC:
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 219424 W: 43681 L: 43103 D: 132640
Ptnml(0-2): 4014, 25760, 49669, 26172, 4097
https://tests.stockfishchess.org/tests/view/601bce167f517a561bc491eb

Passed LTC:
LLR: 2.94 (-2.94,2.94) {0.25,1.25}
Total: 317312 W: 42525 L: 41579 D: 233208
Ptnml(0-2): 2447, 30157, 92636, 30835, 2581
https://tests.stockfishchess.org/tests/view/601c21557f517a561bc49227

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

Bench: 4154473

3 years agoSimplify En Passant
bmc4 [Sun, 31 Jan 2021 13:12:32 +0000 (10:12 -0300)]
Simplify En Passant

simplifies the handling of en passant during search, needs a little more care in initialization.

Passed STC:
LLR: 2.95 (-2.94,2.94) {-1.25,0.25}
Total: 72608 W: 6569 L: 6559 D: 59480
Ptnml(0-2): 233, 5117, 25629, 5057, 268
https://tests.stockfishchess.org/tests/view/600f1363735dd7f0f0352ce7

Passed LTC:
LLR: 2.92 (-2.94,2.94) {-0.75,0.25}
Total: 24328 W: 913 L: 864 D: 22551
Ptnml(0-2): 10, 731, 10633, 780, 10
https://tests.stockfishchess.org/tests/view/600f2e93735dd7f0f0352cf6

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

No functional change.

3 years agoTune ordering of moves at internal nodes
bmc4 [Sun, 31 Jan 2021 03:05:39 +0000 (00:05 -0300)]
Tune ordering of moves at internal nodes

We change the relative weights of the function used to order
quiet moves in our MovePicker class.

Passed STC:
LLR: 2.94 (-2.94,2.94) {-0.25,1.25}
Total: 32184 W: 2936 L: 2773 D: 26475
Ptnml(0-2): 115, 2196, 11328, 2317, 136
https://tests.stockfishchess.org/tests/view/60161ee1735dd7f0f03530f8

Passed LTC:
LLR: 2.93 (-2.94,2.94) {0.25,1.25}
Total: 33088 W: 1292 L: 1149 D: 30647
Ptnml(0-2): 14, 1030, 14318, 1163, 19
https://tests.stockfishchess.org/tests/view/60163146735dd7f0f03530ff

The new weight were chosen after the following SPSA session:
https://tests.stockfishchess.org/tests/view/60136857735dd7f0f0352f6c

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

Bench: 4398803

3 years agoSimplify Chess 960 castling
bmc4 [Sun, 17 Jan 2021 18:21:45 +0000 (15:21 -0300)]
Simplify Chess 960 castling

a little cleanup, and small speedup (about 0.3%) for Chess 960.

Verified with perft on a large set of chess960 positions.

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

No functional change