]> git.sesse.net Git - stockfish/log
stockfish
5 months agoSimplify accumulator refreshes
cj5716 [Wed, 1 May 2024 07:54:17 +0000 (15:54 +0800)]
Simplify accumulator refreshes

Passed Non-Regression STC:
https://tests.stockfishchess.org/tests/view/6631f5d5d01fb9ac9bcdc7d0
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 57472 W: 14979 L: 14784 D: 27709
Ptnml(0-2): 185, 6486, 15192, 6695, 178

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

No functional change

5 months agoAdjust history usage in moves loop pruning
Michael Chaly [Sun, 5 May 2024 02:20:05 +0000 (05:20 +0300)]
Adjust history usage in moves loop pruning

After experiments with conthist 5 addition failed really bad divions by 2 passed as a gainer.

Passed STC:
https://tests.stockfishchess.org/tests/view/6636d7114b68b70d858035ce
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 35936 W: 9287 L: 8976 D: 17673
Ptnml(0-2): 81, 4129, 9234, 4446, 78

Passed LTC:
https://tests.stockfishchess.org/tests/view/6636ddb64b68b70d858040a8
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 82428 W: 21035 L: 20622 D: 40771
Ptnml(0-2): 29, 8985, 22775, 9394, 31

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

Bench: 2309253

5 months agoSome history fixes and tidy-up
cj5716 [Wed, 1 May 2024 10:31:38 +0000 (18:31 +0800)]
Some history fixes and tidy-up

This adds the functions `update_refutations` and `update_quiet_histories` to better distinguish the two. `update_quiet_stats` now just calls both of these functions.

The functional side of this patch is two-fold:
1. Stop refutations being updated when we carry out multicut
2. Update pawn history every time we update other quiet histories

Yellow STC:
LLR: -2.95 (-2.94,2.94) <0.00,2.00>
Total: 238976 W: 61506 L: 61415 D: 116055
Ptnml(0-2): 846, 28628, 60456, 28705, 853
https://tests.stockfishchess.org/tests/view/66321b5ed01fb9ac9bcdca83

However, it passed in <-1.75, 0.25> bounds:
$ python3 sprt.py --wins 61506 --losses 61415 --draws 116055 --elo0 -1.75 --elo1 0.25
ELO: 0.132 +- 0.998 [-0.865, 1.13]
LLR: 4.15 [-1.75, 0.25] (-2.94, 2.94)
H1 Accepted

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 399126 W: 100730 L: 100896 D: 197500
Ptnml(0-2): 116, 44328, 110843, 44158, 118
https://tests.stockfishchess.org/tests/view/66357b0473559a8aa857ba6f

closes #5215

Bench 2370967

5 months agoSimplify shuffling and optimism divisors to constants
FauziAkram [Sat, 4 May 2024 18:43:07 +0000 (21:43 +0300)]
Simplify shuffling and optimism divisors to constants

Shuffling divisor and Optimism divisors passed STC & LTC separately:
shuf STC: https://tests.stockfishchess.org/tests/view/66356316b4e9bdbc7228b995
shuf LTC: https://tests.stockfishchess.org/tests/view/6635815a73559a8aa857c1dc
opt STC: https://tests.stockfishchess.org/tests/view/66356326b4e9bdbc7228b9a0
opt LTC: https://tests.stockfishchess.org/tests/view/663615c673559a8aa8589f8a

And then passed LTC together:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 178278 W: 45039 L: 44979 D: 88260
Ptnml(0-2): 43, 19776, 49460, 19798, 62
https://tests.stockfishchess.org/tests/view/66363f19cdb7cf5da64e22a3

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

Bench: 2198243

5 months agoIntroduce Quadruple Extensions
Viren6 [Sat, 4 May 2024 16:29:23 +0000 (17:29 +0100)]
Introduce Quadruple Extensions

This patch introduces quadruple extensions, with the new condition of not ttPv. It also generalises all margins, so that extensions can still occur if conditions are only partially fulfilled, but with a stricter margin.

Failed STC:
LLR: -2.94 (-2.94,2.94) <0.00,2.00>
Total: 16096 W: 3984 L: 4228 D: 7884
Ptnml(0-2): 72, 2067, 4002, 1847, 60
https://tests.stockfishchess.org/tests/view/66316422d01fb9ac9bcdbdcd

Passed VVLTC 1:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 96660 W: 24550 L: 24210 D: 47900
Ptnml(0-2): 5, 8776, 30426, 9120, 3
https://tests.stockfishchess.org/tests/view/66361f2c74fa3f41ef2ee091

Passed VVLTC 2:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 80546 W: 20495 L: 20120 D: 39931
Ptnml(0-2): 6, 7477, 24929, 7858, 3
https://tests.stockfishchess.org/tests/view/66350cf739ba8e443112b3fa

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

bench 2233743

5 months agoAdd extra bonuses to some moves that forced a fail low
Michael Chaly [Sat, 4 May 2024 07:33:26 +0000 (10:33 +0300)]
Add extra bonuses to some moves that forced a fail low

The previous patch on this idea was giving bonuses to this moves if best value of search is far below current static evaluation.
This patch does similar thing but adds extra bonus when best value of search is far below static evaluation before previous move.

Passed STC:
https://tests.stockfishchess.org/tests/view/66355fc819566d64b481d6a4
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 454144 W: 116575 L: 115656 D: 221913
Ptnml(0-2): 1060, 53410, 117215, 54325, 1062

Passed LTC:
https://tests.stockfishchess.org/tests/view/6635c61a73559a8aa858012d
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 136578 W: 34858 L: 34335 D: 67385

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

Bench: 1614825

5 months agoRemove PSQT-only mode
cj5716 [Sat, 4 May 2024 01:52:27 +0000 (09:52 +0800)]
Remove PSQT-only mode

Passed STC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 94208 W: 24270 L: 24112 D: 45826
Ptnml(0-2): 286, 11186, 24009, 11330, 293
https://tests.stockfishchess.org/tests/view/6635ddd773559a8aa8582826

Passed LTC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 114960 W: 29107 L: 28982 D: 56871
Ptnml(0-2): 37, 12683, 31924, 12790, 46
https://tests.stockfishchess.org/tests/view/663604a973559a8aa85881ed

closes #5214

Bench 1653939

5 months agoClear Workers after changing the network
Disservin [Wed, 1 May 2024 13:10:23 +0000 (15:10 +0200)]
Clear Workers after changing the network

ensures internal state (e.g. accumulator cache) is consistent with network

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

No functional change

6 months agoAccumulator cache bugfix and cleanup
mstembera [Tue, 30 Apr 2024 03:37:54 +0000 (20:37 -0700)]
Accumulator cache bugfix and cleanup

STC:
https://tests.stockfishchess.org/tests/view/663068913a05f1bf7a511dc2
LLR: 2.98 (-2.94,2.94) <-1.75,0.25>
Total: 70304 W: 18211 L: 18026 D: 34067
Ptnml(0-2): 232, 7966, 18582, 8129, 243

1) Fixes a bug introduced in
   https://github.com/official-stockfish/Stockfish/pull/5194. Only one
   psqtOnly flag was used for two perspectives which was causing
   wrong entries to be cleared and marked.
2) The finny caches should be cleared like histories and not at the
   start of every search.

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

No functional change

6 months agoOptimise NNUE Accumulator updates
cj5716 [Sun, 28 Apr 2024 08:33:59 +0000 (16:33 +0800)]
Optimise NNUE Accumulator updates

Passed STC:
https://tests.stockfishchess.org/tests/view/662e3c6a5e9274400985a741
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 86176 W: 22284 L: 21905 D: 41987
Ptnml(0-2): 254, 9572, 23051, 9963, 248

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

No functional change

6 months agoAvoid unnecessary creation of accumulator cache
Ciekce [Mon, 29 Apr 2024 00:45:56 +0000 (01:45 +0100)]
Avoid unnecessary creation of accumulator cache

Saves a (currently) 800 KB allocation and deallocation when running
`eval`, not particularly significant and zero impact on play but not
necessary either.

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

No functional change

6 months agoUse capture history to better judge which sacrifices to explore
Dubslow [Sat, 20 Apr 2024 05:29:01 +0000 (00:29 -0500)]
Use capture history to better judge which sacrifices to explore

This idea has been bouncing around a while. @Vizvezdenec tried it a
couple years ago in Stockfish without results, but its recent arrival in
Ethereal inspired him and thence me to try it afresh in Stockfish.

(Also factor out the now-common code with futpruning for captures.)

STC:
https://tests.stockfishchess.org/tests/view/662355bc3fe04ce4cefc18ac
LLR: 2.92 (-2.94,2.94) <0.00,2.00>
Total: 45760 W: 11970 L: 11640 D: 22150
Ptnml(0-2): 124, 5371, 11625, 5571, 189

LTC:
https://tests.stockfishchess.org/tests/view/662dda396115ff6764c817c9
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 243828 W: 62042 L: 61287 D: 120499
Ptnml(0-2): 211, 27202, 66329, 27965, 207

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

Bench: 1480008

6 months agoMore reduction at cut nodes which are not a former PV node
Stefan Geschwentner [Sun, 28 Apr 2024 14:53:47 +0000 (16:53 +0200)]
More reduction at cut nodes which are not a former PV node

But the tt move and first killer are excluded.

This idea is based on following LMR condition tuning
https://tests.stockfishchess.org/tests/view/66228bed3fe04ce4cefc0c71 by
using only the two largest terms P[0] and P[1].

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 173248 W: 45091 L: 44565 D: 83592
Ptnml(0-2): 693, 20534, 43673, 21002, 722
https://tests.stockfishchess.org/tests/view/6629603b3fe04ce4cefc7d37

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 722394 W: 183231 L: 181487 D: 357676
Ptnml(0-2): 462, 80650, 197252, 82348, 485
https://tests.stockfishchess.org/tests/view/662cbe45d46f72253dcff7bf

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

Bench: 1619613

6 months agoSimplify non-pawn material divisor to a constant
Stefan Geschwentner [Sun, 28 Apr 2024 14:04:28 +0000 (16:04 +0200)]
Simplify non-pawn material divisor to a constant

Passed STC:
https://tests.stockfishchess.org/tests/view/662942603fe04ce4cefc7aba
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 272832 W: 70456 L: 70497 D: 131879
Ptnml(0-2): 1020, 32619, 69154, 32628, 995

Passed LTC:
https://tests.stockfishchess.org/tests/view/662dfe3b6115ff6764c829eb
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 100254 W: 25446 L: 25303 D: 49505
Ptnml(0-2): 121, 11292, 27166, 11419, 129

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

Bench: 1544645

6 months agoPenalise the TT move in multicut
cj5716 [Sun, 28 Apr 2024 00:53:28 +0000 (08:53 +0800)]
Penalise the TT move in multicut

Passed STC:
LLR: 2.99 (-2.94,2.94) <0.00,2.00>
Total: 185504 W: 48079 L: 47533 D: 89892
Ptnml(0-2): 716, 21866, 46988, 22520, 662
https://tests.stockfishchess.org/tests/view/662d9e1d6115ff6764c7f83d

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 75612 W: 19351 L: 18948 D: 37313
Ptnml(0-2): 46, 8363, 20592, 8752, 53
https://tests.stockfishchess.org/tests/view/662dc9dc6115ff6764c80fea

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

Bench: 1415435

6 months agoCombine remove and add in update_accumulator_refresh_cache()
mstembera [Sun, 28 Apr 2024 17:28:25 +0000 (10:28 -0700)]
Combine remove and add in update_accumulator_refresh_cache()

Combine remove and add in update_accumulator_refresh_cache().
Move remove before add to match other parts of the code.

STC:
https://tests.stockfishchess.org/tests/view/662d96dc6115ff6764c7f4ca
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 364032 W: 94421 L: 93624 D: 175987
Ptnml(0-2): 1261, 41983, 94811, 42620, 1341

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

Bench: 1836777

6 months agoCache small net w/ psqtOnly support
mstembera [Fri, 26 Apr 2024 01:20:08 +0000 (18:20 -0700)]
Cache small net w/ psqtOnly support

Caching the small net in the same way as the big net allows them to
share the same code path and completely removes
update_accumulator_refresh().

STC:
https://tests.stockfishchess.org/tests/view/662bfb5ed46f72253dcfed85
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 151712 W: 39252 L: 39158 D: 73302
Ptnml(0-2): 565, 17474, 39683, 17570, 564

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

Bench: 1836777

6 months agoOutput some basic info about the used networks
Joost VandeVondele [Sat, 27 Apr 2024 16:09:45 +0000 (18:09 +0200)]
Output some basic info about the used networks

Adds size in memory as well as layer sizes as in

info string NNUE evaluation using nn-ae6a388e4a1a.nnue (132MiB, (22528, 3072, 15, 32, 1))
info string NNUE evaluation using nn-baff1ede1f90.nnue (6MiB, (22528, 128, 15, 32, 1))

For example, the size in MiB is useful to keep the fishtest memory sizes up-to-date,
the L1-L3 sizes give a useful hint about the architecture used.

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

No functional change

6 months agoFix missing initialization of AccumulatorCaches in Eval::trace
Disservin [Thu, 25 Apr 2024 17:20:57 +0000 (19:20 +0200)]
Fix missing initialization of AccumulatorCaches in Eval::trace

Add a constructor to `AccumulatorCaches` instead of just calling
`clear(networks)` to prevent similar issues from appearing in the
future.

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

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

No functional change

6 months agoUse less time on recaptures
xoto10 [Sun, 28 Apr 2024 15:27:40 +0000 (16:27 +0100)]
Use less time on recaptures

Credit for the idea goes to peregrine on discord.

Passed STC 10+0.1:
https://tests.stockfishchess.org/tests/view/662652623fe04ce4cefc48cf
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 75712 W: 19793 L: 19423 D: 36496
Ptnml(0-2): 258, 8487, 20023, 8803, 285

Passed LTC 60+0.6:
https://tests.stockfishchess.org/tests/view/6627495e3fe04ce4cefc59b6
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 49788 W: 12743 L: 12404 D: 24641
Ptnml(0-2): 29, 5141, 14215, 5480, 29

The code was updated slightly and tested for non-regression against the
original code at STC:

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 41952 W: 10912 L: 10698 D: 20342
Ptnml(0-2): 133, 4825, 10835, 5061, 122
https://tests.stockfishchess.org/tests/view/662d84f56115ff6764c7e438

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

Bench: 1836777

6 months agoImplement accumulator refresh table
gab8192 [Sat, 20 Apr 2024 19:26:00 +0000 (21:26 +0200)]
Implement accumulator refresh table

For each thread persist an accumulator cache for the network, where each
cache contains multiple entries for each of the possible king squares.
When the accumulator needs to be refreshed, the cached entry is used to more
efficiently update the accumulator, instead of rebuilding it from scratch.
This idea, was first described by Luecx (author of Koivisto) and
is commonly referred to as "Finny Tables".

When the accumulator needs to be refreshed, instead of filling it with
biases and adding every piece from scratch, we...

1. Take the `AccumulatorRefreshEntry` associated with the new king bucket
2. Calculate the features to activate and deactivate (from differences
   between bitboards in the entry and bitboards of the actual position)
3. Apply the updates on the refresh entry
4. Copy the content of the refresh entry accumulator to the accumulator
   we were refreshing
5. Copy the bitboards from the position to the refresh entry, to match
   the newly updated accumulator

Results at STC:
https://tests.stockfishchess.org/tests/view/662301573fe04ce4cefc1386
(first version)
https://tests.stockfishchess.org/tests/view/6627fa063fe04ce4cefc6560
(final)

Non-Regression between first and final:
https://tests.stockfishchess.org/tests/view/662801e33fe04ce4cefc660a

STC SMP:
https://tests.stockfishchess.org/tests/view/662808133fe04ce4cefc667c

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

No functional change

6 months agoTune Search Parameters
FauziAkram [Mon, 22 Apr 2024 11:34:22 +0000 (14:34 +0300)]
Tune Search Parameters

Parameters Tune, adding also another tunable parameter (npmDiv) to be
variable for different nets (bignet, smallnet, psqtOnly smallnet). P.s:
The changed values are only the parameters where there is agreement
among the different time controls, so in other words, the tunings are
telling us that changing these specific values to this specific
direction is good in all time controls, so there shouldn't be a high
risk of regressing at longer time controls.

Passed STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 39552 W: 10329 L: 9999 D: 19224
Ptnml(0-2): 156, 4592, 9989, 4844, 195
https://tests.stockfishchess.org/tests/view/661be9a0bd68065432a088c0

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 56394 W: 14439 L: 14078 D: 27877
Ptnml(0-2): 30, 6152, 15480, 6497, 38
https://tests.stockfishchess.org/tests/view/661c746296961e72eb565406

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

Bench: 1836777

6 months agoRestore NPS output for Perft
Disservin [Mon, 22 Apr 2024 17:24:10 +0000 (19:24 +0200)]
Restore NPS output for Perft

Previously it was possible to also get the node counter after running a bench with perft, i.e.
`./stockfish bench 1 1 5 current perft`, caused by a small regression from the uci refactoring.

```
Nodes searched: 4865609

===========================
Total time (ms) : 18
Nodes searched  : 4865609
Nodes/second    : 270311611
````

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

No functional change

6 months agoTweak TT aging and replacement strategies
cj5716 [Thu, 18 Apr 2024 10:50:09 +0000 (18:50 +0800)]
Tweak TT aging and replacement strategies

We change the definition of "age" from "age of this position" to "age of this TT entry".
In this way, despite being on the same position, when we save into TT, we always prefer the new entry as compared to the old one.

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 152256 W: 39597 L: 39110 D: 73549
Ptnml(0-2): 556, 17562, 39398, 18063, 549
https://tests.stockfishchess.org/tests/view/6620faee3fe04ce4cefbf215

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 51564 W: 13242 L: 12895 D: 25427
Ptnml(0-2): 24, 5464, 14463, 5803, 28
https://tests.stockfishchess.org/tests/view/66231ab53fe04ce4cefc153e

closes #5184

Bench 1479416

6 months agoMove ALSR change to CI Workflow file
Disservin [Sat, 20 Apr 2024 18:37:39 +0000 (20:37 +0200)]
Move ALSR change to CI Workflow file

It makes more sense to not (potentially) change the developers alsr entropy setting to make the test run through. This should be an active choice even if the test then might fail locally for them.

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

No functional change

6 months agoImprove CI
Joost VandeVondele [Sat, 20 Apr 2024 13:33:07 +0000 (15:33 +0200)]
Improve CI

the recent refactoring has shown some limitations of our testing, hence we add a couple of more tests including:
* expected mate score
* expected mated score
* expected in TB win score
* expected in TB loss score
* expected info line output
* expected info line output (wdl)

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

No functional change

6 months agoupdate the WDL model
Robert Nurnberg @ elitebook [Tue, 16 Apr 2024 06:23:42 +0000 (08:23 +0200)]
update the WDL model

The patch only changes the displayed cp and wdl values.

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

No functional change

6 months agofix clang compiler warning for avx512 build
Gahtan Nahdi [Mon, 15 Apr 2024 04:55:28 +0000 (11:55 +0700)]
fix clang compiler warning for avx512 build

Initialize variable in constexpr function to get rid of clang compiler warning for avx512 build.

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

Non-functional change

6 months agoTrivial cleanup
Michael Chaly [Thu, 11 Apr 2024 21:00:59 +0000 (00:00 +0300)]
Trivial cleanup

Make naming and declaration of futilityValue in search consistent between different places.

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

No functional change.

6 months agoRefactor elapsed time checks in search
Disservin [Wed, 10 Apr 2024 21:10:07 +0000 (23:10 +0200)]
Refactor elapsed time checks in search

Small improvement of the elapsed time usage in search, makes the code easier to read overall.
Also Search::Worker::iterative_deepening() now only checks the elapsed time once, instead of 3 times in a row.

Non Regression STC:
https://tests.stockfishchess.org/tests/view/6617005d5a4693796d965c3c
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 61024 W: 16002 L: 15806 D: 29216
Ptnml(0-2): 243, 6874, 16102, 7030, 263

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

No functional change

6 months agoUpdate outdated comments
Disservin [Sun, 7 Apr 2024 12:26:23 +0000 (14:26 +0200)]
Update outdated comments

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

No functional change

6 months agoFix wrong sign for 200 TB score
Disservin [Sat, 13 Apr 2024 19:54:10 +0000 (21:54 +0200)]
Fix wrong sign for 200 TB score

Fix another case of 9032c6cbe74ccf7e8963755501e7e6cc473ae471

*    TB values can have a distance of 0, mainly when we are in a tb position but haven't found mate.
*    Add a missing whitespace to UCIEngine::on_update_no_moves()

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

No functional change

6 months agoRemove duplicated Position object in UCIEngine
Disservin [Fri, 12 Apr 2024 17:11:10 +0000 (19:11 +0200)]
Remove duplicated Position object in UCIEngine

Also fixes searchmoves.

Drop the need of a Position object in uci.cpp.

A side note, it is still required for the static functions,
but these should be moved to a different namespace/class
later on, since sf kinda relies on them.

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

No functional change

6 months agoFix some more UCI output
Shahin M. Shahin [Fri, 12 Apr 2024 10:32:31 +0000 (13:32 +0300)]
Fix some more UCI output

further fall-out of the refactoring, fixes:

* the position object in UCI is not never getting updated if position token is used
* duplicate string of " wdl "

See also:

https://discord.com/channels/435943710472011776/1032922913499783169/1228227522945351690
https://discord.com/channels/435943710472011776/813919248455827515/1228288106449338398

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

No functional change

Co-Authored-By: disservin <45608332+disservin@users.noreply.github.com>
6 months agoFix wrong mate sign
Robert Nurnberg @ elitebook [Fri, 12 Apr 2024 06:39:39 +0000 (08:39 +0200)]
Fix wrong mate sign

introduced yesterday by the UCI refactoring 9032c6cbe

fixes #5166
closes https://github.com/official-stockfish/Stockfish/pull/5167

No functional change

6 months agoSimplify the depth-dependent part of the best value adjustment formula in main search
FauziAkram [Thu, 11 Apr 2024 11:00:46 +0000 (14:00 +0300)]
Simplify the depth-dependent part of the best value adjustment formula in main search

Passed STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 139648 W: 36171 L: 36061 D: 67416
Ptnml(0-2): 545, 16685, 35282, 16739, 573
https://tests.stockfishchess.org/tests/view/660d953b8ff4a059828d625d

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 222894 W: 56519 L: 56505 D: 109870
Ptnml(0-2): 112, 25145, 60971, 25055, 164
https://tests.stockfishchess.org/tests/view/660fd4afbfeb43334bf7d558

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

bench: 1479416

6 months agoRemove an useless assignment
gab8192 [Wed, 3 Apr 2024 21:41:24 +0000 (23:41 +0200)]
Remove an useless assignment

The assignment (ss + 1)->excludedMove = Move::none() can be simplified away because when that line is reached, (ss + 1)->excludedMove is always already none. The only moment stack[x]->excludedMove is modified, is during singular search, but it is reset to none right after the singular search is finished.

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

No functional change

6 months agoRemove COMPILER from Makefile
Disservin [Fri, 5 Apr 2024 09:34:11 +0000 (11:34 +0200)]
Remove COMPILER from Makefile

The same functionality is available by using COMPCXX and having another variable which does the same is just confusing.
There was only one mention on Stockfish Wiki about this which has been changed to COMPCXX.

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

No functional change

6 months agoAvoid permuting inputs during transform()
mstembera [Mon, 8 Apr 2024 20:07:41 +0000 (13:07 -0700)]
Avoid permuting inputs during transform()

Avoid permuting inputs during transform() and instead do it once at load time.
Affects AVX2 and newer Intel architectures only.

https://tests.stockfishchess.org/tests/view/661306613eb00c8ccc0033c7
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 108480 W: 28319 L: 27898 D: 52263
Ptnml(0-2): 436, 12259, 28438, 12662, 445

speedups measured such as e.g.

```
Result of 100 runs
==================
base (./stockfish.master       ) =    1241128  +/- 3757
test (./stockfish.patch        ) =    1247713  +/- 3689
diff                             =      +6585  +/- 2583

speedup        = +0.0053
P(speedup > 0) =  1.0000
```

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

No functional change

6 months agoVVLTC search tune
Muzhen Gaming [Sat, 6 Apr 2024 14:39:29 +0000 (22:39 +0800)]
VVLTC search tune

Parameters were tuned in 3 stages:

* Using an earlier L1-3072 net, and with triple extension margin manually set to 0: https://tests.stockfishchess.org/tests/view/65ffdf5d0ec64f0526c544f2 (~30k games)
* Continue tuning, but with the previous master net (L1-2560). https://tests.stockfishchess.org/tests/view/660663f00ec64f0526c59c41 (~27k games)
* Starting with the parameters from step 2, use the current L1-3072 net, and allow the triple extension margin to be tuned starting from 0: https://tests.stockfishchess.org/tests/view/660c16b8216a13d9498e7536 (40k games)

Passed VVLTC 1st sprt: https://tests.stockfishchess.org/tests/view/66115eacbfeb43334bf7eddd
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 27138 W: 7045 L: 6789 D: 13304
Ptnml(0-2): 1, 2421, 8471, 2673, 3

Passed VVLTC 2nd sprt: https://tests.stockfishchess.org/tests/view/661483623eb00c8ccc0049c1
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 26242 W: 6807 L: 6535 D: 12900
Ptnml(0-2): 0, 2353, 8143, 2625, 0

STC Elo estimate: https://tests.stockfishchess.org/tests/view/66175ca55a4693796d96608c
Elo: -10.53 ± 2.4 (95%) LOS: 0.0%
Total: 21584 W: 5294 L: 5948 D: 10342
Ptnml(0-2): 102, 2937, 5363, 2293, 97
nElo: -19.99 ± 4.7 (95%) PairsRatio: 0.79

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

Bench: 1381387

6 months agoTransform search output to engine callbacks
Disservin [Sat, 23 Mar 2024 09:22:20 +0000 (10:22 +0100)]
Transform search output to engine callbacks

Part 2 of the Split UCI into UCIEngine and Engine refactor.
This creates function callbacks for search to use when an update should occur.
The benching in uci.cpp for example does this to extract the total nodes
searched.

No functional change

6 months agoSplit UCI into UCIEngine and Engine
Disservin [Sun, 17 Mar 2024 11:33:14 +0000 (12:33 +0100)]
Split UCI into UCIEngine and Engine

This is another refactor which aims to decouple uci from stockfish. A new engine
class manages all engine related logic and uci is a "small" wrapper around it.

In the future we should also try to remove the need for the Position object in
the uci and replace the options with an actual options struct instead of using a
map. Also convert the std::string's in the Info structs a string_view.

closes #5147

No functional change

7 months agoUpdate NNUE architecture to SFNNv9 and net nn-ae6a388e4a1a.nnue
Viren6 [Tue, 2 Apr 2024 03:38:54 +0000 (04:38 +0100)]
Update NNUE architecture to SFNNv9 and net nn-ae6a388e4a1a.nnue

Part 1: PyTorch Training, linrock

Trained with a 10-stage sequence from scratch, starting in May 2023:
https://github.com/linrock/nnue-tools/blob/master/exp-sequences/3072-10stage-SFNNv9.yml

While the training methods were similar to the L1-2560 training sequence,
the last two stages introduced min-v2 binpacks,
where bestmove capture and in-check position scores were not zeroed during minimization,
for compatibility with skipping SEE >= 0 positions and future research.

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

This net was tested at epoch 679 of the 10th training stage:
https://tests.stockfishchess.org/tests/view/65f32e460ec64f0526c48dbc

Part 2: SPSA Training, Viren6

The net was then SPSA tuned.
This consisted of the output weights (32 * 8) and biases (8)
as well as the L3 biases (32 * 8) and L2 biases (16 * 8), totalling 648 params in total.

The SPSA tune can be found here:
https://tests.stockfishchess.org/tests/view/65fc33ba0ec64f0526c512e3

With the help of Disservin , the initial weights were extracted with:
https://github.com/Viren6/Stockfish/tree/new228

The net was saved with the tuned weights using:
https://github.com/Viren6/Stockfish/tree/new241

Earlier nets of the SPSA failed STC compared to the base 3072 net of part 1:
https://tests.stockfishchess.org/tests/view/65ff356e0ec64f0526c53c98
Therefore it is suspected that the SPSA at VVLTC has
added extra scaling on top of the scaling of increasing the L1 size.

Passed VVLTC 1:
https://tests.stockfishchess.org/tests/view/6604a9020ec64f0526c583da
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 53042 W: 13554 L: 13256 D: 26232
Ptnml(0-2): 12, 5147, 15903, 5449, 10

Passed VVLTC 2:
https://tests.stockfishchess.org/tests/view/660ad1b60ec64f0526c5dd23
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 17506 W: 4574 L: 4315 D: 8617
Ptnml(0-2): 1, 1567, 5362, 1818, 5

STC Elo estimate:
https://tests.stockfishchess.org/tests/view/660b834d01aaec5069f87cb0
Elo: -7.66 ± 3.8 (95%) LOS: 0.0%
Total: 9618 W: 2440 L: 2652 D: 4526
Ptnml(0-2): 80, 1281, 2261, 1145, 42
nElo: -13.94 ± 6.9 (95%) PairsRatio: 0.87

closes https://tests.stockfishchess.org/tests/view/660b834d01aaec5069f87cb0

bench 1823302

Co-Authored-By: Linmiao Xu <lin@robotmoon.com>
7 months agoAvoid a note related to an ABI change
Joost VandeVondele [Sat, 30 Mar 2024 09:54:36 +0000 (10:54 +0100)]
Avoid a note related to an ABI change

current master triggers a gcc note:
parameter passing for argument of type 'std::pair<double, double>' when C++17 is enabled changed to match C++14 in GCC 10.1

while this is inconsequential, and just informative  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111516 we can easily avoid it.

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

No functional change

7 months agoImprove prerelease creation workflow
Disservin [Fri, 29 Mar 2024 09:49:53 +0000 (10:49 +0100)]
Improve prerelease creation workflow

In the last couple of months we sometimes saw duplicated prereleases uploaded to GitHub, possibly due to some racy behavior when concurrent jobs create a prerelease. This now creates an empty prerelease at the beginning of the CI and the binaries are later just attached to this one.

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

No functional change

7 months agoFix usage of abs vs std::abs
Joost VandeVondele [Fri, 29 Mar 2024 09:25:41 +0000 (10:25 +0100)]
Fix usage of abs vs std::abs

close https://github.com/official-stockfish/Stockfish/pull/5143

No functional change

7 months agoSimplify NMP Condition
Shawn Xu [Wed, 27 Mar 2024 09:58:59 +0000 (02:58 -0700)]
Simplify NMP Condition

Remove eval >= ss->staticEval condition for Null Move Pruning.

Passed non-regression STC:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 44000 W: 11420 L: 11202 D: 21378
Ptnml(0-2): 174, 5243, 10978, 5401, 204
https://tests.stockfishchess.org/tests/live_elo/6603ee490ec64f0526c57984

Passed non-regression LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 82956 W: 20978 L: 20818 D: 41160
Ptnml(0-2): 54, 9353, 22499, 9523, 49
https://tests.stockfishchess.org/tests/live_elo/660464b50ec64f0526c5804d

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

Bench 1759189

7 months agoAdjust best value after a pruned quiet move
Michael Chaly [Thu, 28 Mar 2024 21:17:37 +0000 (00:17 +0300)]
Adjust best value after a pruned quiet move

Logic somewhat similar to how we adjust best value after pruned captures
in qsearch, but in search this patch does it after pruned quiet moves
and also to not full scale of futility value but to smth in between
best value and futility value.

Passed STC:
https://tests.stockfishchess.org/tests/view/6601cf900ec64f0526c55c30
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 59936 W: 15722 L: 15369 D: 28845
Ptnml(0-2): 182, 7097, 15112, 7340, 237

Passed LTC:
https://tests.stockfishchess.org/tests/view/66029b2d0ec64f0526c566f1
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 118362 W: 29953 L: 29460 D: 58949
Ptnml(0-2): 68, 13159, 32249, 13622, 83

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

bench 1772608

7 months agoVary time use with eval
xoto10 [Wed, 27 Mar 2024 08:20:49 +0000 (08:20 +0000)]
Vary time use with eval

Adjust time use depending on the current eval.

Passed STC :
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 101696 W: 26651 L: 26238 D: 48807
Ptnml(0-2): 400, 11602, 26459, 11959, 428
https://tests.stockfishchess.org/tests/live_elo/660187a50ec64f0526c557f6

Passed LTC :
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 60648 W: 15550 L: 15187 D: 29911
Ptnml(0-2): 40, 6356, 17171, 6715, 42
https://tests.stockfishchess.org/tests/live_elo/660298ed0ec64f0526c566d0

Values were found using two tunes with the final values taken from the ltc tune after 62k games :
stc - https://tests.stockfishchess.org/tests/view/65fb526b0ec64f0526c50694
ltc - https://tests.stockfishchess.org/tests/view/65fd36e60ec64f0526c5214b

Ideas for future work;

  * tune these values with the other TM adjustments
  * try narrower bands
  * calculate adjustment for exact eval by interpolation

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

No functional change

7 months agoRemove material imbalance from nnue eval
Gahtan Nahdi [Fri, 22 Mar 2024 20:48:44 +0000 (03:48 +0700)]
Remove material imbalance from nnue eval

Passed non-reg STC:
https://tests.stockfishchess.org/tests/view/65fdf11f0ec64f0526c52b57
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 76480 W: 19893 L: 19712 D: 36875
Ptnml(0-2): 339, 9107, 19157, 9308, 329

Passed non-reg LTC:
https://tests.stockfishchess.org/tests/view/65fee22e0ec64f0526c53885
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 150948 W: 38078 L: 37988 D: 74882
Ptnml(0-2): 111, 16997, 41148, 17127, 91

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

Bench: 2103324

7 months agoTweak the stats bonus and malus
FauziAkram [Sun, 24 Mar 2024 11:02:27 +0000 (14:02 +0300)]
Tweak the stats bonus and malus

For depth 1 we don't have a negative score anymore.

Passed STC:
https://tests.stockfishchess.org/tests/view/65fb055c0ec64f0526c5024f
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 117120 W: 30468 L: 30023 D: 56629
Ptnml(0-2): 526, 13759, 29539, 14216, 520

Passed LTC:
https://tests.stockfishchess.org/tests/view/65fdca4b0ec64f0526c5293f
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 54816 W: 13955 L: 13595 D: 27266
Ptnml(0-2): 30, 6046, 14897, 6404, 31

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

Bench: 1876428

7 months agoAdd functionality to export small net
Disservin [Sat, 23 Mar 2024 09:34:32 +0000 (10:34 +0100)]
Add functionality to export small net

Usage
```
export_net <filenameBigNet> <filenameSmallNet>
```

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

No functional change

7 months agoUpdate nnue_feature_transformer.h
mstembera [Thu, 21 Mar 2024 08:25:59 +0000 (01:25 -0700)]
Update nnue_feature_transformer.h

Unroll update_accumulator_refresh to process two
active indices simultaneously.

The compiler might not unroll effectively because
the number of active indices isn't known at
compile time.

STC https://tests.stockfishchess.org/tests/view/65faa8850ec64f0526c4fca9
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 130464 W: 33882 L: 33431 D: 63151
Ptnml(0-2): 539, 14591, 34501, 15082, 519

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

No functional change

7 months agoVVLTC search tune
Muzhen Gaming [Sun, 17 Mar 2024 03:20:41 +0000 (11:20 +0800)]
VVLTC search tune

This set of parameters was derived from 3 tuning attempts:

    https://tests.stockfishchess.org/tests/view/65d19ab61d8e83c78bfd8436 (80+0.8 x8, ~40k games)
    Then tuned with one of linrock's early L1-3072 nets:
    https://tests.stockfishchess.org/tests/view/65def7b04b19edc854ebdec8 (VVLTC, ~36k games)
    Starting from the result of this tuning, the parameters were then tuned with the current master net:
    https://tests.stockfishchess.org/tests/view/65f11c420ec64f0526c46fc4 (VVLTC, ~45k games)

Additionally, at the start of the third tuning phase, 2 parameters were manually changed:

    Notably, the triple extension margin was decreased from 78 to 22. This idea was given by Vizvezdenec:
    https://tests.stockfishchess.org/tests/view/65f0a2360ec64f0526c46752.
    The PvNode extension margin was also adjusted from 50 to 40.

This tune also differs from previous tuning attempts by tuning the evaluation thresholds for smallnet and psqt-only.
The former was increased through the tuning, and this is hypothesized to scale better at VVLTC,
although there is not much evidence of it.

Passed VVLTC 1st sprt: https://tests.stockfishchess.org/tests/view/65f6761d0ec64f0526c4be88
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 44688 W: 11421 L: 11140 D: 22127
Ptnml(0-2): 1, 4170, 13722, 4449, 2

Passed VVLTC 2nd sprt: https://tests.stockfishchess.org/tests/view/65fa31a30ec64f0526c4f611
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 27450 W: 7057 L: 6778 D: 13615
Ptnml(0-2): 4, 2545, 8346, 2828, 2

STC Elo estimate: https://tests.stockfishchess.org/tests/view/65fd3e540ec64f0526c521ae
Elo: -7.84 ± 1.8 (95%) LOS: 0.0%
Total: 40000 W: 9899 L: 10802 D: 19299
Ptnml(0-2): 203, 5221, 10025, 4378, 173
nElo: -14.91 ± 3.4 (95%) PairsRatio: 0.84

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

Bench: 1876107

7 months agoAdd cmath header to movepick.h
Disservin [Wed, 20 Mar 2024 15:36:10 +0000 (16:36 +0100)]
Add cmath header to movepick.h

No functional change

7 months agoRemove reduction increase on repetition
Gahtan Nahdi [Mon, 18 Mar 2024 19:45:09 +0000 (02:45 +0700)]
Remove reduction increase on repetition

Passed non-reg STC:
https://tests.stockfishchess.org/tests/view/65f89ae30ec64f0526c4e0ff
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 173568 W: 45005 L: 44936 D: 83627
Ptnml(0-2): 684, 19878, 45628, 19873, 721

Passed non-reg LTC:
https://tests.stockfishchess.org/tests/view/65fa0f370ec64f0526c4f42d
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 21138 W: 5432 L: 5216 D: 10490
Ptnml(0-2): 13, 2107, 6112, 2325, 12

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

Bench: 2109005

7 months agoEvaluation adjustment for different eval types
Gahtan Nahdi [Fri, 15 Mar 2024 09:50:27 +0000 (16:50 +0700)]
Evaluation adjustment for different eval types

Gives different eval scaling parameters for the three different types
of evaluation (bignet, smallnet, psqtOnly).

Passed STC:
https://tests.stockfishchess.org/tests/view/65f4b0020ec64f0526c4a3bd
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 168064 W: 43507 L: 42987 D: 81570
Ptnml(0-2): 662, 19871, 42445, 20393, 661

Passed LTC:
https://tests.stockfishchess.org/tests/view/65f6be1a0ec64f0526c4c361
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 162564 W: 41188 L: 40604 D: 80772
Ptnml(0-2): 120, 18112, 44216, 18732, 102

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

Bench: 2113576

7 months agoBase WDL model on material count and normalize evals dynamically
Robert Nurnberg [Sun, 17 Mar 2024 14:39:01 +0000 (15:39 +0100)]
Base WDL model on material count and normalize evals dynamically

This PR proposes to change the parameter dependence of Stockfish's
internal WDL model from full move counter to material count. In addition
it ensures that an evaluation of 100 centipawns always corresponds to a
50% win probability at fishtest LTC, whereas for master this holds only
at move number 32. See also
https://github.com/official-stockfish/Stockfish/pull/4920 and the
discussion therein.

The new model was fitted based on about 340M positions extracted from
5.6M fishtest LTC games from the last three weeks, involving SF versions
from e67cc979fd2c0e66dfc2b2f2daa0117458cfc462 (SF 16.1) to current
master.

The involved commands are for
[WDL_model](https://github.com/official-stockfish/WDL_model) are:
```
./updateWDL.sh --firstrev e67cc979fd2c0e66dfc2b2f2daa0117458cfc462
python scoreWDL.py updateWDL.json --plot save --pgnName update_material.png --momType "material" --momTarget 58 --materialMin 10 --modelFitting optimizeProbability
```

The anchor `58` for the material count value was chosen to be as close
as possible to the observed average material count of fishtest LTC games
at move 32 (`43`), while not changing the value of
`NormalizeToPawnValue` compared to the move-based WDL model by more than
1.

The patch only affects the displayed cp and wdl values.

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

No functional change

7 months agoFix header name in Makefile
Disservin [Sun, 17 Mar 2024 11:34:02 +0000 (12:34 +0100)]
Fix header name in Makefile

No functional change

7 months agoConsistent use of anonymous namespace
Disservin [Sun, 17 Mar 2024 09:33:03 +0000 (10:33 +0100)]
Consistent use of anonymous namespace

Also change `bindThisThread` to match the current code style for function naming.

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

No functional change

7 months agoClamp history bonus to stats range
Michael Chaly [Fri, 15 Mar 2024 15:55:40 +0000 (18:55 +0300)]
Clamp history bonus to stats range

Before, one always had to keep track of the bonus one assigns to a history to stop
the stats from overflowing. This is a quality of life improvement. Since this would often go unnoticed during benching.

Passed non-regression bounds:
https://tests.stockfishchess.org/tests/view/65ef2af40ec64f0526c44cbc
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 179232 W: 46513 L: 46450 D: 86269
Ptnml(0-2): 716, 20323, 47452, 20432, 693

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

No functional change

7 months agoFix false positives from ThreadSanitizer
Disservin [Thu, 14 Mar 2024 09:38:20 +0000 (10:38 +0100)]
Fix false positives from ThreadSanitizer

Since Linux Kernel 6.5 we are getting false positives from the ci,
lower the ALSR entropy to disable ALSR, which works as a temporary
workaround.

https://github.com/google/sanitizers/issues/1716
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2056762

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

No functional change

7 months agoMake effort part of RootMove struct
cj5716 [Wed, 13 Mar 2024 07:55:56 +0000 (15:55 +0800)]
Make effort part of RootMove struct

Also includes several small cleanups.

Passed STC:
https://tests.stockfishchess.org/tests/view/65f15cfe0ec64f0526c473a0
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 71136 W: 18456 L: 18273 D: 34407
Ptnml(0-2): 311, 8014, 18708, 8251, 284

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

No functional change

7 months agoSudden Death - Improve TM
Lemmy [Sun, 10 Mar 2024 21:57:22 +0000 (07:57 +1000)]
Sudden Death - Improve TM

Due to the 50 estimated move horizon, once a sudden death game got below
1 second, the time allocation for optimumTime would go into the negative
and SF would start instamoving.

To counter this, once limits.time is below 1 second, the move horizon
will start decreasing, at a rate of 1 move per 20ms. This was just what
seemed a reasonable rate of decay.

Fishtest sudden death TC 5+0
https://tests.stockfishchess.org/tests/live_elo/65ee2cdf0ec64f0526c43bbb
LLR: 2.99 (-2.94,2.94) <0.00,2.00>
Total: 3348 W: 1070 L: 727 D:1551
Ptnml(0-2): 46, 277, 738, 514, 99

Fishtest SD TC 10+0
https://tests.stockfishchess.org/tests/live_elo/65ee401e0ec64f0526c43cf7
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 3780 W: 1097 L: 808 D: 1875
Ptnml(0-2): 11, 353, 919, 550, 57

Neutral Non-Regression STC 10+0.1
https://tests.stockfishchess.org/tests/live_elo/65ee45ff0ec64f0526c43d68
LLR: 2.95 (-2.94,2.94) <-1.75, 0.25>
Total: 123616 W: 32054 L: 31927 D:59635
Ptnml(0-2): 493, 14323, 32105, 14338, 549

Neutral Non-Regression LTC 60+0.6
https://tests.stockfishchess.org/tests/live_elo/65ef1eec0ec64f0526c44bc4
LLR: 2.95 (-2.94,2.94) <-1.75, 0.25>
Total: 130482 W: 32961 L: 32855 D:64666
Ptnml(0-2): 88, 13412, 38123, 13542, 76

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

Bench: 2002517

7 months agoGive more bonuses to quiet move that caused a fail low
Michael Chaly [Wed, 13 Mar 2024 16:21:13 +0000 (19:21 +0300)]
Give more bonuses to quiet move that caused a fail low

Give extra bonus if search result is far below static evaluation of
position.

Passed STC:
https://tests.stockfishchess.org/tests/view/65edf1250ec64f0526c43787
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 90816 W: 23713 L: 23307 D: 43796
Ptnml(0-2): 401, 10725, 22742, 11147, 393

Passed LTC:
https://tests.stockfishchess.org/tests/view/65ef5ed70ec64f0526c450af
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 66618 W: 16950 L: 16565 D: 33103
Ptnml(0-2): 35, 7372, 18139, 7699, 64

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

Bench: 2002517

7 months agoFix Raspberry Pi Compilation
Disservin [Tue, 12 Mar 2024 17:20:19 +0000 (18:20 +0100)]
Fix Raspberry Pi Compilation

Reported by @Torom over discord.

> dev build fails on Raspberry Pi 5 with clang

```
clang++ -o stockfish benchmark.o bitboard.o evaluate.o main.o misc.o movegen.o movepick.o position.o search.o thread.o timeman.o tt.o uci.o ucioption.o tune.o tbprobe.o nnue_misc.o half_ka_v2_hm.o network.o  -fprofile-instr-generate -latomic -lpthread  -Wall -Wcast-qual -fno-exceptions -std=c++17 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wmissing-prototypes -Wconditional-uninitialized -DUSE_PTHREADS -DNDEBUG -O3 -funroll-loops -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8 -march=armv8.2-a+dotprod -DUSE_NEON_DOTPROD -DGIT_SHA=627974c9 -DGIT_DATE=20240312 -DARCH=armv8-dotprod -flto=full
/tmp/lto-llvm-e9300e.o: in function `_GLOBAL__sub_I_network.cpp':
ld-temp.o:(.text.startup+0x704c): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `gEmbeddedNNUEBigEnd' defined in .rodata section in /tmp/lto-llvm-e9300e.o
/usr/bin/ld: ld-temp.o:(.text.startup+0x704c): warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined
ld-temp.o:(.text.startup+0x7068): relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol `gEmbeddedNNUESmallEnd' defined in .rodata section in /tmp/lto-llvm-e9300e.o
/usr/bin/ld: ld-temp.o:(.text.startup+0x7068): warning: one possible cause of this error is that the symbol is being referenced in the indicated code as if it had a larger alignment than was declared where it was defined
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [Makefile:1051: stockfish] Error 1
make[2]: Leaving directory '/home/torsten/chess/Stockfish_master/src'
make[1]: *** [Makefile:1058: clang-profile-make] Error 2
make[1]: Leaving directory '/home/torsten/chess/Stockfish_master/src'
make: *** [Makefile:886: profile-build] Error 2
```

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

No functional change

7 months agoSearch + Eval + Movepick Tune
FauziAkram [Tue, 12 Mar 2024 14:10:28 +0000 (17:10 +0300)]
Search + Eval + Movepick Tune

Passed STC:
https://tests.stockfishchess.org/tests/view/65ef15220ec64f0526c44b04
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 24480 W: 6459 L: 6153 D: 11868
Ptnml(0-2): 101, 2798, 6184, 3008, 149

Passed LTC:
https://tests.stockfishchess.org/tests/view/65ef4bac0ec64f0526c44f50
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 53316 W: 13561 L: 13203 D: 26552
Ptnml(0-2): 27, 5925, 14408, 6259, 39

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

Bench: 1715522

7 months agoSimplify increaseDepth to boolean expression
FauziAkram [Sat, 9 Mar 2024 16:49:59 +0000 (19:49 +0300)]
Simplify increaseDepth to boolean expression

Non-functional Simplification, maintaining the same logic as before. Big thanks
to @peregrineshahin for helping with the code.

Passed non-regression bounds:
https://tests.stockfishchess.org/tests/view/65ec93860ec64f0526c42375
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 101088 W: 26196 L: 26047 D: 48845
Ptnml(0-2): 405, 11580, 26473, 11633, 453

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

No functional change

7 months agoRefactor Network Usage
Disservin [Sat, 9 Mar 2024 13:42:37 +0000 (14:42 +0100)]
Refactor Network Usage

Continuing from PR #4968, this update improves how Stockfish handles network
usage, making it easier to manage and modify networks in the future.

With the introduction of a dedicated Network class, creating networks has become
straightforward. See uci.cpp:
```cpp
NN::NetworkBig({EvalFileDefaultNameBig, "None", ""}, NN::embeddedNNUEBig)
```

The new `Network` encapsulates all network-related logic, significantly reducing
the complexity previously required to support multiple network types, such as
the distinction between small and big networks #4915.

Non-Regression STC:
https://tests.stockfishchess.org/tests/view/65edd26c0ec64f0526c43584
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 33760 W: 8887 L: 8661 D: 16212
Ptnml(0-2): 143, 3795, 8808, 3961, 173

Non-Regression SMP STC:
https://tests.stockfishchess.org/tests/view/65ed71970ec64f0526c42fdd
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 59088 W: 15121 L: 14931 D: 29036
Ptnml(0-2): 110, 6640, 15829, 6880, 85

Compiled with `make -j profile-build`
```
bash ./bench_parallel.sh ./stockfish ./stockfish-nnue 13 50

sf_base =  1568540 +/-   7637 (95%)
sf_test =  1573129 +/-   7301 (95%)
diff    =     4589 +/-   8720 (95%)
speedup = 0.29260% +/- 0.556% (95%)
```

Compiled with `make -j build`
```
bash ./bench_parallel.sh ./stockfish ./stockfish-nnue 13 50

sf_base =  1472653 +/-   7293 (95%)
sf_test =  1491928 +/-   7661 (95%)
diff    =    19275 +/-   7154 (95%)
speedup = 1.30886% +/- 0.486% (95%)
```

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

No functional change

7 months agoSimplify opponentWorsening condition
Gahtan Nahdi [Sun, 10 Mar 2024 23:25:07 +0000 (06:25 +0700)]
Simplify opponentWorsening condition

Passed non-reg STC:
https://tests.stockfishchess.org/tests/view/65ea18650ec64f0526c4033a
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 226624 W: 58601 L: 58589 D: 109434
Ptnml(0-2): 1030, 27193, 56819, 27275, 995

Passed non-reg LTC:
https://tests.stockfishchess.org/tests/view/65eb7a220ec64f0526c4161a
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 243882 W: 61462 L: 61469 D: 120951
Ptnml(0-2): 197, 27559, 66419, 27586, 180

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

Bench: 1601012

7 months agoVVLTC search tune
Muzhen Gaming [Mon, 11 Mar 2024 08:58:21 +0000 (09:58 +0100)]
VVLTC search tune

Result of 32k games of tuning at 60+0.6 8-thread. Link to the tuning
attempt:
https://tests.stockfishchess.org/tests/view/65def7b04b19edc854ebdec8

Passed VVLTC first SPRT:
https://tests.stockfishchess.org/tests/view/65e51b53416ecd92c162ab7f
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 37570 W: 9613 L: 9342 D: 18615
Ptnml(0-2): 2, 3454, 11601, 3727, 1

Passed VVLTC second SPRT:
https://tests.stockfishchess.org/tests/view/65e87d1c0ec64f0526c3eb39
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 123158 W: 31463 L: 31006 D: 60689
Ptnml(0-2): 5, 11589, 37935, 12044, 6

Note: The small net and psqt-only thresholds have been moved to
evaluate.h. The reasoning is that these values are used in both
`evaluate.cpp` and `evaluate_nnue.cpp`, and thus unifying their usage
avoids inconsistencies during testing, where one occurrence is changed
without the other (this happened during the search tune SPRT).

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

Bench: 1741218

7 months agoAssorted cleanups
Disservin [Sat, 9 Mar 2024 11:14:57 +0000 (12:14 +0100)]
Assorted cleanups

- fix naming convention for `workingDirectory`
- use type alias for `EvalFiles` everywhere
- move `ponderMode` into `LimitsType`
- move limits parsing into standalone static function

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

No functional change

7 months agoFix wrong constant usage in go mate
Robert Nurnberg @ elitebook [Thu, 7 Mar 2024 21:01:40 +0000 (22:01 +0100)]
Fix wrong constant usage in go mate

Fixes an oversight in https://github.com/official-stockfish/Stockfish/pull/5094

In theory, master could stop search when run with `go mate 247` and return a TB loss (not a mate score). Also fixes the spelling of opponenWorsening.

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

No functional change

7 months agoVLTC time management tune
Muzhen Gaming [Mon, 4 Mar 2024 10:48:02 +0000 (18:48 +0800)]
VLTC time management tune

Result of 35k games of SPSA tuning at 180+1.8. Tuning attempt can be
found here:
https://tests.stockfishchess.org/tests/view/65e40599f2ef6c733362b03b

Passed VLTC 180+1.8:
https://tests.stockfishchess.org/tests/view/65e5a6f5416ecd92c162b5d4
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 31950 W: 8225 L: 7949 D: 15776
Ptnml(0-2): 3, 3195, 9309, 3459, 9

Passed VLTC 240+2.4:
https://tests.stockfishchess.org/tests/view/65e714de0ec64f0526c3d1f1
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 65108 W: 16558 L: 16202 D: 32348
Ptnml(0-2): 7, 6366, 19449, 6728, 4

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

Bench: 1714391

7 months agoFix `go mate x` in multithreading
Shahin M. Shahin [Wed, 6 Mar 2024 17:56:55 +0000 (20:56 +0300)]
Fix `go mate x` in multithreading

Fixes two issues with master for go mate x:

- when running go mate x in losing positions, master always goes to the
  maximal depth, arguably against what the UCI protocol demands

- when running go mate x in winning positions with multiple
  threads, master may return non-mate scores from the search (this issue
  is present in stockfish since at least sf16) The issues are fixed by
  (a) also checking if score is mate -x and by (b) only letting
  mainthread stop the search for go mate x commands, and by not looking
  for a best thread but using mainthread as per the default. Related:
    niklasf/python-chess#1070

More diagnostics can be found here peregrineshahin#6 (comment)

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

No functional change

Co-Authored-By: Robert Nürnberg <28635489+robertnurnberg@users.noreply.github.com>
7 months agoIntroduce double extensions for PV nodes
Michael Chaly [Thu, 7 Mar 2024 08:57:18 +0000 (11:57 +0300)]
Introduce double extensions for PV nodes

Our double/triple extensions were allowed only for non-pv nodes. This
patch allows them to be done for PV nodes, with some stricter
conditions.

Passed STC:
https://tests.stockfishchess.org/tests/view/65d657ec1d8e83c78bfddab8
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 339424 W: 88097 L: 87318 D: 164009
Ptnml(0-2): 1573, 39935, 85729, 41090, 1385

Passed LTC:
https://tests.stockfishchess.org/tests/view/65dd63824b19edc854ebc433
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 459564 W: 115812 L: 114614 D: 229138
Ptnml(0-2): 248, 51441, 125173, 52705, 215

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

Bench: 1714391

7 months agoReduce futility_margin if opponents last move was bad
rn5f107s2 [Thu, 15 Feb 2024 22:01:02 +0000 (23:01 +0100)]
Reduce futility_margin if opponents last move was bad

This reduces the futiltiy_margin if our opponents last move was bad by
around ~1/3 when not improving and ~1/2.7 when improving, the idea being
to retroactively futility prune moves that were played, but turned out
to be bad.  A bad move is being defined as their staticEval before their
move being lower as our staticEval now is. If the depth is 2 and we are
improving the opponent worsening flag is not set, in order to not risk
having a too low futility_margin, due to the fact that when these
conditions are met the futility_margin already drops quite low.

Passed STC:
https://tests.stockfishchess.org/tests/live_elo/65e3977bf2ef6c733362aae3
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 122432 W: 31884 L: 31436 D: 59112
Ptnml(0-2): 467, 14404, 31035, 14834, 476

Passed LTC:
https://tests.stockfishchess.org/tests/live_elo/65e47f40f2ef6c733362b6d2
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 421692 W: 106572 L: 105452 D: 209668
Ptnml(0-2): 216, 47217, 114865, 48327, 221

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

Bench: 1565939

7 months agoUpdate default main net to nn-1ceb1ade0001.nnue
Linmiao Xu [Fri, 1 Mar 2024 18:34:03 +0000 (10:34 -0800)]
Update default main net to nn-1ceb1ade0001.nnue

Created by retraining the previous main net `nn-b1a57edbea57.nnue` with:
- some of the same options as before:
  - ranger21, more WDL skipping, 15% more loss when Q is too high
- removal of the huge 514G pre-interleaved binpack
- removal of SF-generated dfrc data (dfrc99-16tb7p-filt-v2.min.binpack)
- interleaving many binpacks at training time
- training with some bestmove capture positions where SEE < 0
- increased usage of torch.compile to speed up training by up to 40%

```yaml
experiment-name: 2560--S10-dfrc0-to-dec2023-skip-more-wdl-15p-more-loss-high-q-see-ge0-sk28
nnue-pytorch-branch: linrock/nnue-pytorch/r21-more-wdl-skip-15p-more-loss-high-q-skip-see-ge0-torch-compile-more
start-from-engine-test-net: True

early-fen-skipping: 28
training-dataset:
  # similar, not the exact same as:
  # https://github.com/official-stockfish/Stockfish/pull/4635
  - /data/S5-5af/leela96.v2.min.binpack
  - /data/S5-5af/test60-2021-11-12-novdec-12tb7p.v6-dd.min.binpack
  - /data/S5-5af/test77-2021-12-dec-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test78-2022-01-to-05-jantomay-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test78-2022-06-to-09-juntosep-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test79-2022-04-apr-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test79-2022-05-may-16tb7p.v6-dd.min.binpack

  - /data/S5-5af/test80-2022-06-jun-16tb7p.v6-dd.min.unmin.binpack
  - /data/S5-5af/test80-2022-07-jul-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test80-2022-08-aug-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test80-2022-09-sep-16tb7p.v6-dd.min.unmin.binpack
  - /data/S5-5af/test80-2022-10-oct-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test80-2022-11-nov-16tb7p.v6-dd.min.binpack

  - /data/S5-5af/test80-2023-01-jan-16tb7p.v6-sk20.min.binpack
  - /data/S5-5af/test80-2023-02-feb-16tb7p.v6-dd.min.binpack
  - /data/S5-5af/test80-2023-03-mar-2tb7p.min.unmin.binpack
  - /data/S5-5af/test80-2023-04-apr-2tb7p.binpack
  - /data/S5-5af/test80-2023-05-may-2tb7p.min.dd.binpack

  # https://github.com/official-stockfish/Stockfish/pull/4782
  - /data/S6-1ee1aba5ed/test80-2023-06-jun-2tb7p.binpack
  - /data/S6-1ee1aba5ed/test80-2023-07-jul-2tb7p.min.binpack

  # https://github.com/official-stockfish/Stockfish/pull/4972
  - /data/S8-baff1edbea57/test80-2023-08-aug-2tb7p.v6.min.binpack
  - /data/S8-baff1edbea57/test80-2023-09-sep-2tb7p.binpack
  - /data/S8-baff1edbea57/test80-2023-10-oct-2tb7p.binpack

  # https://github.com/official-stockfish/Stockfish/pull/5056
  - /data/S9-b1a57edbea57/test80-2023-11-nov-2tb7p.binpack
  - /data/S9-b1a57edbea57/test80-2023-12-dec-2tb7p.binpack

num-epochs: 800
lr: 4.375e-4
gamma: 0.995
start-lambda: 1.0
end-lambda: 0.7
```

This particular net was reached at epoch 759. Use of more torch.compile decorators
in nnue-pytorch model.py than in the previous main net training run sped up training
by up to 40% on Tesla gpus when using recent pytorch compiled with cuda 12:
https://github.com/linrock/nnue-tools/blob/7fb9831/Dockerfile

Skipping positions with bestmove captures where static exchange evaluation is >= 0
is based on the implementation from Sopel's NNUE training & experimentation log:
https://docs.google.com/document/d/1gTlrr02qSNKiXNZ_SuO4-RjK4MXBiFlLE6jvNqqMkAY
Experiment 293 - only skip captures with see>=0

Positions with bestmove captures where score == 0 are always skipped for
compatibility with minimized binpacks, since the original minimizer sets
scores to 0 for slight improvements in compression.

The trainer branch used was:
https://github.com/linrock/nnue-pytorch/tree/r21-more-wdl-skip-15p-more-loss-high-q-skip-see-ge0-torch-compile-more

Binpacks were renamed to be sorted chronologically by default when sorted by name.
The binpack data are otherwise the same as binpacks with similar names in the prior
naming convention.

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

Passed STC:
https://tests.stockfishchess.org/tests/view/65e3ddd1f2ef6c733362ae5c
LLR: 2.92 (-2.94,2.94) <0.00,2.00>
Total: 149792 W: 39153 L: 38661 D: 71978
Ptnml(0-2): 675, 17586, 37905, 18032, 698

Passed LTC:
https://tests.stockfishchess.org/tests/view/65e4d91c416ecd92c162a69b
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 64416 W: 16517 L: 16135 D: 31764
Ptnml(0-2): 38, 7218, 17313, 7602, 37

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

Bench: 1373183

7 months agoUpdate elo estimates
FauziAkram [Mon, 4 Mar 2024 13:13:36 +0000 (16:13 +0300)]
Update elo estimates

Tests used to change the elo worth of some functions:

https://tests.stockfishchess.org/tests/view/65c3f69dc865510db0283eef
https://tests.stockfishchess.org/tests/view/65c3f935c865510db0283f2a
https://tests.stockfishchess.org/tests/view/65d1489f1d8e83c78bfd7dbf
https://tests.stockfishchess.org/tests/view/65ce9d361d8e83c78bfd4951
https://tests.stockfishchess.org/tests/view/65cfcd901d8e83c78bfd6184

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

No functional change

7 months agoSimplify Time Management
FauziAkram [Mon, 26 Feb 2024 15:08:22 +0000 (18:08 +0300)]
Simplify Time Management

Instead of having a formula for using extra time with larger increments.
Simply set it to 1 when the increment is lower than 0.5s and to 1.1 when
the increment is higher.

The values can later on be further improved.

Passed STC:
https://tests.stockfishchess.org/tests/view/65d25d3c1d8e83c78bfd9293
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 27488 W: 7077 L: 6848 D: 13563
Ptnml(0-2): 96, 3041, 7267, 3218, 122

Passed LTC:
https://tests.stockfishchess.org/tests/view/65d2a72c1d8e83c78bfd97fa
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 137568 W: 34612 L: 34512 D: 68444
Ptnml(0-2): 60, 14672, 39221, 14770, 61

Passed VLTC:
https://tests.stockfishchess.org/tests/view/65d7d7d39b2da0226a5a205b
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 139650 W: 35229 L: 35134 D: 69287
Ptnml(0-2): 33, 14227, 41218, 14306, 41

Passed also the TCEC TC style suggested by vondele:
https://tests.stockfishchess.org/tests/view/65e4ca73416ecd92c162a57d
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 134150 W: 34278 L: 34163 D: 65709
Ptnml(0-2): 561, 15727, 34444, 15722, 621

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

Bench: 1553115

7 months agoSimplify extension when ttMove is assumed to fail high over current beta
Gahtan Nahdi [Wed, 21 Feb 2024 21:37:26 +0000 (04:37 +0700)]
Simplify extension when ttMove is assumed to fail high over current beta

Simplify extension value to -3 when ttMove is assumed to fail high over current beta.

Passed non-reg STC:
https://tests.stockfishchess.org/tests/view/65d66ed81d8e83c78bfddcba
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 235136 W: 60711 L: 60708 D: 113717
Ptnml(0-2): 969, 27904, 59874, 27797, 1024

Passed non-reg LTC:
https://tests.stockfishchess.org/tests/view/65da2994944f2a78d4733107
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 662850 W: 166161 L: 166602 D: 330087
Ptnml(0-2): 394, 74895, 181274, 74482, 380

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

Bench: 1553115

7 months agoSimplify IIR
Gahtan Nahdi [Sun, 18 Feb 2024 06:47:52 +0000 (13:47 +0700)]
Simplify IIR

Simplified depth reduction for PV nodes without a ttMove to 3.

Passed STC non-reg:
https://tests.stockfishchess.org/tests/view/65d1a90a1d8e83c78bfd855a
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 363168 W: 93648 L: 93791 D: 175729
Ptnml(0-2): 1557, 43692, 91221, 43565, 1549

Passed LTC non-reg:
https://tests.stockfishchess.org/tests/view/65d5612d1d8e83c78bfdc8e2
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 58818 W: 14946 L: 14761 D: 29111
Ptnml(0-2): 36, 6595, 15962, 6780, 36

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

Bench: 1505827

7 months agoOnly evaluate the PSQT part of the small net for large evals.
mstembera [Thu, 29 Feb 2024 22:27:00 +0000 (14:27 -0800)]
Only evaluate the PSQT part of the small net for large evals.

Thanks to Viren6 for suggesting to set complexity to 0.

STC https://tests.stockfishchess.org/tests/view/65d7d6709b2da0226a5a203f
LLR: 2.92 (-2.94,2.94) <0.00,2.00>
Total: 328384 W: 85316 L: 84554 D: 158514
Ptnml(0-2): 1414, 39076, 82486, 39766, 1450

LTC https://tests.stockfishchess.org/tests/view/65dce6d290f639b028a54d2e
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 165162 W: 41918 L: 41330 D: 81914
Ptnml(0-2): 102, 18332, 45124, 18922, 101

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

bench: 1504003

7 months agoDocument TT code more
Disservin [Tue, 20 Feb 2024 21:47:26 +0000 (22:47 +0100)]
Document TT code more

Slight refactor of the TT code with the goal to make it easier to understand / tweak.

Passed Non-Regression STC:
https://tests.stockfishchess.org/tests/view/65d51e401d8e83c78bfdc427
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 56416 W: 14750 L: 14550 D: 27116
Ptnml(0-2): 227, 6386, 14796, 6558, 241

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

No functional change

7 months agoJoin conditions for move sorting heuristics
Gahtan Nahdi [Tue, 27 Feb 2024 12:27:40 +0000 (19:27 +0700)]
Join conditions for move sorting heuristics

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

No functional change.

7 months agoUpdate Actions to Node20
Disservin [Sun, 25 Feb 2024 10:16:55 +0000 (11:16 +0100)]
Update Actions to Node20

ensure our CI continues to run after Node16 is obsolote on github.

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

No functional change

7 months agoMake binaries executable again in CI
Disservin [Sat, 24 Feb 2024 19:30:40 +0000 (20:30 +0100)]
Make binaries executable again in CI

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

No functional change

7 months agoRestore development
Disservin [Sat, 24 Feb 2024 19:40:48 +0000 (20:40 +0100)]
Restore development

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

No functional change

8 months agoStockfish 16.1
Disservin [Wed, 21 Feb 2024 21:17:23 +0000 (22:17 +0100)]
Stockfish 16.1

Official release version of Stockfish 16.1

Bench: 1303971

---

Stockfish 16.1

Today, we have the pleasure to announce Stockfish 16.1. As always, you can
freely download it at https://stockfishchess.org/download and use it in the GUI
of your choice[1].

Don't forget to join our Discord server[2] to get in touch with the community of
developers and users of the project!

*Quality of chess play*

In our testing against its predecessor, Stockfish 16.1 shows a notable
improvement in performance, with an Elo gain of up to 27 points and winning over
2 times more game pairs[3] than it loses.

*Update highlights*

*Improved evaluation*

- Updated neural network architecture: The neural network architecture has
  undergone two updates and is currently in its 8th version[4].
- Removal of handcrafted evaluation (HCE): This release marks the removal of the
  traditional handcrafted evaluation and the transition to a fully neural
  network-based approach[5].
- Dual NNUE: For the first time, Stockfish includes a secondary neural
  network[6], used to quickly evaluate positions that are easily decided.

*UCI Options removed*

`Use NNUE` and `UCI_AnalyseMode`[7] have been removed as they no longer had any
effect. `SlowMover`[8] has also been removed in favor of `Move Overhead`.

*More binaries*

We now offer 13 new binaries. These new binaries include `avx512`, `vnni256`,
`vnni512`, `m1-apple-silicon`, and `armv8-dotprod`, which take advantage of
specific CPU instructions for improved performance.
For most users, using `sse41-popcnt` (formerly `modern`), `avx2`, or `bmi2`
should be enough, but if your CPU supports these new instructions, feel free to
try them!

*Development changes*

- Updated testing book: This new book[9], now derived exclusively from the open
  Lichess database[10], is 10 times larger than its predecessor, and has been
  used to test potential improvements to Stockfish over the past few months.
- Consolidation of repositories: Aiming to simplify access to our resources, we
  have moved most Stockfish-related repositories into the official Stockfish
  organization[11] on GitHub.
- Growing maintainer team: We welcome Disservin[12] to the team of maintainers
  of the project! This extra pair of hands will ensure the lasting success of
  Stockfish.

*Thank you*

The Stockfish project builds on a thriving community of enthusiasts (thanks
everybody!) 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 express our gratitude for the 10k stars[13] that light up our
GitHub project! Thank you for your support and encouragement – your recognition
means a lot to us.

We invite our chess fans to join the Fishtest testing framework[14], and
programmers to contribute to the project either directly to Stockfish[15] (C++),
to Fishtest[16] (HTML, CSS, JavaScript, and Python), to our trainer
nnue-pytorch[17] (C++ and Python), or to our website[18] (HTML, CSS/SCSS, and
JavaScript).

The Stockfish team

[1] https://github.com/official-stockfish/Stockfish/wiki/Download-and-usage#download-a-chess-gui
[2] https://discord.gg/GWDRS3kU6R
[3] https://tests.stockfishchess.org/tests/view/65d666051d8e83c78bfddbd8
[4] https://github.com/official-stockfish/nnue-pytorch/blob/master/docs/nnue.md#sfnnv8-architecture
[5] https://github.com/official-stockfish/Stockfish/commit/af110e0
[6] https://github.com/official-stockfish/Stockfish/commit/584d9ef
[7] https://github.com/official-stockfish/Stockfish/commit/c53d2ec
[8] https://github.com/official-stockfish/Stockfish/commit/536d692
[9] https://github.com/official-stockfish/books/commit/426eca4
[10] https://database.lichess.org/
[11] https://github.com/official-stockfish/
[12] https://github.com/Disservin
[13] https://github.com/official-stockfish/Stockfish/stargazers
[14] https://github.com/official-stockfish/fishtest/wiki/Running-the-worker
[15] https://github.com/official-stockfish/Stockfish
[16] https://github.com/official-stockfish/fishtest
[17] https://github.com/official-stockfish/nnue-pytorch
[18] https://github.com/official-stockfish/stockfish-web

8 months agoUpdate the WDL model
Robert Nurnberg @ elitebook [Sat, 24 Feb 2024 16:55:08 +0000 (17:55 +0100)]
Update the WDL model

Based on 130M positions from 2.1M games.

```
Look recursively in directory pgns for games from SPRT tests using books
matching "UHO_4060_v..epd|UHO_Lichess_4852_v1.epd" for SF revisions
between 8e75548f2a10969c1c9211056999efbcebe63f9a (from 2024-02-17
17:11:46 +0100) and HEAD (from 2024-02-17 17:13:07 +0100). Based on
127920843 positions from 2109240 games, NormalizeToPawnValue should
change from 345 to 356.
```

The patch only affects the UCI-reported cp and wdl values.

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

No functional change

8 months agoUpdate Top CPU Contributors
Disservin [Sat, 24 Feb 2024 16:54:06 +0000 (17:54 +0100)]
Update Top CPU Contributors

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

No functional change

8 months agoExpose EvalFileSmall option for small net
Disservin [Sat, 24 Feb 2024 10:56:33 +0000 (11:56 +0100)]
Expose EvalFileSmall option for small net

Since https://github.com/official-stockfish/fishtest/pull/1870 has been merged
it's time for this update.

5k Fixed Games showed no problems.
https://tests.stockfishchess.org/tests/view/65d9cc274c0e22b904f574d7

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

No functional change

8 months agoSimplify PV node reduction
cj5716 [Tue, 13 Feb 2024 09:46:37 +0000 (17:46 +0800)]
Simplify PV node reduction

Reduce less on PV nodes even with an upperbound TT entry.

Passed STC:
https://tests.stockfishchess.org/tests/view/65cb3a861d8e83c78bfd0497
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 118752 W: 30441 L: 30307 D: 58004
Ptnml(0-2): 476, 14179, 29921, 14335, 465

Passed LTC:
https://tests.stockfishchess.org/tests/view/65cd3b951d8e83c78bfd2b0d
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 155058 W: 38549 L: 38464 D: 78045
Ptnml(0-2): 85, 17521, 42219, 17632, 72

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

Bench: 1303971

8 months agoUpdate default main net to nn-b1a57edbea57.nnue
Linmiao Xu [Tue, 6 Feb 2024 16:21:15 +0000 (11:21 -0500)]
Update default main net to nn-b1a57edbea57.nnue

Created by retraining the previous main net `nn-baff1edbea57.nnue` with:
- some of the same options as before: ranger21, more WDL skipping
- the addition of T80 nov+dec 2023 data
- increasing loss by 15% when prediction is too high, up from 10%
- use of torch.compile to speed up training by over 25%

```yaml
experiment-name: 2560--S9-514G-T80-augtodec2023-more-wdl-skip-15p-more-loss-high-q-sk28

training-dataset:
  # https://github.com/official-stockfish/Stockfish/pull/4782
  - /data/S6-514G-1ee1aba5ed.binpack
  - /data/test80-aug2023-2tb7p.v6.min.binpack
  - /data/test80-sep2023-2tb7p.binpack
  - /data/test80-oct2023-2tb7p.binpack
  - /data/test80-nov2023-2tb7p.binpack
  - /data/test80-dec2023-2tb7p.binpack
early-fen-skipping: 28

start-from-engine-test-net: True
nnue-pytorch-branch: linrock/nnue-pytorch/r21-more-wdl-skip-15p-more-loss-high-q-torch-compile

num-epochs: 1000
lr: 4.375e-4
gamma: 0.995
start-lambda: 1.0
end-lambda: 0.7
```

Epoch 819 trained with the above config led to this PR. Use of torch.compile
decorators in nnue-pytorch model.py was found to speed up training by at least
25% on Ampere gpus when using recent pytorch compiled with cuda 12:
https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch

See recent main net PRs for more info on
- ranger21 and more WDL skipping: https://github.com/official-stockfish/Stockfish/pull/4942
- increasing loss when Q is too high: https://github.com/official-stockfish/Stockfish/pull/4972

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

Passed STC:
https://tests.stockfishchess.org/tests/view/65cd76151d8e83c78bfd2f52
LLR: 2.98 (-2.94,2.94) <0.00,2.00>
Total: 78336 W: 20504 L: 20115 D: 37717
Ptnml(0-2): 317, 9225, 19721, 9562, 343

Passed LTC:
https://tests.stockfishchess.org/tests/view/65ce5be61d8e83c78bfd43e9
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 41016 W: 10492 L: 10159 D: 20365
Ptnml(0-2): 22, 4533, 11071, 4854, 28

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

Bench: 1351997

8 months agoSimplify TT PV reduction
cj5716 [Tue, 13 Feb 2024 09:50:16 +0000 (17:50 +0800)]
Simplify TT PV reduction

This also removes some incorrect fail-high logic.

Passed STC:
https://tests.stockfishchess.org/tests/view/65cb3b641d8e83c78bfd04a9
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 87968 W: 22634 L: 22468 D: 42866
Ptnml(0-2): 315, 10436, 22323, 10588, 322

Passed LTC:
https://tests.stockfishchess.org/tests/view/65cccee21d8e83c78bfd222c
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 70794 W: 17846 L: 17672 D: 35276
Ptnml(0-2): 44, 7980, 19189, 8126, 58

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

Bench: 1474424

8 months agoRemove penalty for quiet ttMove that fails low
Gahtan Nahdi [Fri, 9 Feb 2024 20:51:05 +0000 (03:51 +0700)]
Remove penalty for quiet ttMove that fails low

Passed STC non-reg:
https://tests.stockfishchess.org/tests/view/65c691a7c865510db0286e6e
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 234336 W: 60258 L: 60255 D: 113823
Ptnml(0-2): 966, 28141, 58918, 28210, 933

Passed LTC non-reg:
https://tests.stockfishchess.org/tests/view/65c8d0d31d8e83c78bfcd4a6
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 235206 W: 59134 L: 59132 D: 116940
Ptnml(0-2): 135, 26908, 63517, 26906, 137

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

Bench: 1287996

8 months agoUse node counting to early stop search
Disservin [Sun, 11 Feb 2024 13:19:44 +0000 (14:19 +0100)]
Use node counting to early stop search

This introduces a form of node counting which can
be used to further tweak the usage of our search
time.
The current approach stops the search when almost
all nodes are searched on a single move.

The idea originally came from Koivisto, but the
implemention is a bit different, Koivisto scales
the optimal time by the nodes effort and then
determines if the search should be stopped.
We just scale down the `totalTime` and stop the
search if we exceed it and the effort is large
enough.

Passed STC:
https://tests.stockfishchess.org/tests/view/65c8e0661d8e83c78bfcd5ec
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 88672 W: 22907 L: 22512 D: 43253
Ptnml(0-2): 310, 10163, 23041, 10466, 356

Passed LTC:
https://tests.stockfishchess.org/tests/view/65ca632b1d8e83c78bfcf554
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 170856 W: 42910 L: 42320 D: 85626
Ptnml(0-2): 104, 18337, 47960, 18919, 108

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

Bench: 1198939

8 months agoRefactor timeman.cpp
Tierynn Byrnes [Tue, 6 Feb 2024 04:55:28 +0000 (14:55 +1000)]
Refactor timeman.cpp

Move optExtra, optConstant and maxConstant into lower scope.

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

No functional change

8 months agoVVLTC search tune
Muzhen Gaming [Tue, 13 Feb 2024 10:59:05 +0000 (18:59 +0800)]
VVLTC search tune

Search parameters were tuned using 16k games at
VVLTC. They were tuned starting with the new
parameters (in search only) of PR #5039.

Passed VVLTC:
https://tests.stockfishchess.org/tests/view/65c8a8fc1d8e83c78bfcd163
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 20826 W: 5355 L: 5100 D: 10371
Ptnml(0-2): 1, 1941, 6275, 2194, 2

Passed 2nd VVLTC:
https://tests.stockfishchess.org/tests/view/65cadc2d1d8e83c78bfcfdaf
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 17710 W: 4611 L: 4352 D: 8747
Ptnml(0-2): 1, 1586, 5422, 1845, 1

STC Elo estimate:
https://tests.stockfishchess.org/tests/view/65cb6aed1d8e83c78bfd0802
Elo: -1.46 ± 1.8 (95%) LOS: 5.5%
Total: 40000 W: 10267 L: 10435 D: 19298
Ptnml(0-2): 200, 4860, 10023, 4742, 175
nElo: -2.77 ± 3.4 (95%) PairsRatio: 0.97

Bench: 1198939

8 months agoFormat code using clang-format
Disservin [Sun, 11 Feb 2024 19:13:19 +0000 (20:13 +0100)]
Format code using clang-format

No functional change