Commit Graph
7014 Commits
Author SHA1 Message Date
J. OsterandJoost VandeVondele 5f3dcb92ee Simplify stalemate detection in qsearch.
Conditions for no pawn pushes, non-pawn material and last captured piece are already such restrictive that we don't need to artificially set checkers bitboard for legal move generation.
Also moving the check for available pawn pushes at first place, as it should already filter about 90% of cases.

Passed STC and LTC non-regression tests.
 LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 171232 W: 44202 L: 44131 D: 82899
Ptnml(0-2): 466, 18809, 47023, 18824, 494
https://tests.stockfishchess.org/tests/view/69d3623b61a12cebe17ededa

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 55662 W: 14424 L: 14247 D: 26991
Ptnml(0-2): 38, 5479, 16609, 5678, 27
https://tests.stockfishchess.org/tests/view/69d64cada07a818b0a25f95e

And also neutral on 10k fixed games test with custom stalemate book.
 Elo: 0.24 ± 0.9 (95%) LOS: 69.9%
Total: 10000 W: 4681 L: 4674 D: 645
Ptnml(0-2): 0, 87, 4819, 94, 0
nElo: 1.81 ± 6.8 (95%) PairsRatio: 1.08
https://tests.stockfishchess.org/tests/view/69d7e4183ca80bdf151d43b8

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

Bench: 2984258
2026-04-15 20:15:36 +02:00
DubslowandJoost VandeVondele 3cce652564 Simplify relative_age and its constants
STC: https://tests.stockfishchess.org/tests/view/69cf29ed1668971c9da23a5a
LLR: 3.47 (-2.94,2.94) <-1.75,0.25>
Total: 193760 W: 50142 L: 50051 D: 93567
Ptnml(0-2): 534, 21375, 52980, 21448, 543

* Simplify retval and arithmetic semantics
* Remove mixing of int and uint8_t

I find this overall much easier to reason about

(Also rename a DEPTH constant per mstembera's suggestion https://github.com/official-stockfish/Stockfish/pull/5766#issuecomment-2586449296)

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

No functional change
2026-04-15 20:13:22 +02:00
DisservinandJoost VandeVondele 9bdf2f8d4c Update main network to nn-f68ec79f0fe3.nnue
Trained with the following yaml definition https://github.com/Disservin/nettest/blob/8da0a21503adb341bc89ca20b4e2f166c7c9720d/threats.yaml

and the following trainer change
https://github.com/official-stockfish/nnue-pytorch/commit/d87c248fbed584d08df59820ae0dd309e9b35c85

Initially I saw a lot of weird 0 scores in the binpack, since then @linrock has explained to me/us their meaning and mentioned that they are actually mostly skipped.. except a very small percentage, however it seems this change was still beneficial.

Passed STC:
https://tests.stockfishchess.org/tests/view/69db95f43ca80bdf151d4913
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 106272 W: 27916 L: 27489 D: 50867
Ptnml(0-2): 420, 12533, 26841, 12884, 458

Passed LTC:
https://tests.stockfishchess.org/tests/view/69ddd9003ca80bdf151d4c4d
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 29748 W: 7775 L: 7470 D: 14503
Ptnml(0-2): 24, 3136, 8247, 3445, 22

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

Bench: 3108996
2026-04-15 20:06:17 +02:00
mstemberaandJoost VandeVondele 7959885747 Interpolate highBestMoveEffort
STC: https://tests.stockfishchess.org/tests/view/69d586a64088e069540a22aa
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 63520 W: 16579 L: 16233 D: 30708
Ptnml(0-2): 138, 7179, 16825, 7435, 183

LTC: https://tests.stockfishchess.org/tests/view/69d6ddd79ffee997bab13a98
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 227100 W: 58279 L: 57591 D: 111230
Ptnml(0-2): 95, 23435, 65828, 24071, 121

Transition highBestMoveEffort smoothly instead of abruptly. May also be more amenable to future tuning.

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

Bench: 2923401
2026-04-15 20:03:49 +02:00
Ryan LefkowitzandJoost VandeVondele bb5f0100b0 fix syzygy crash on Apple Silicon by unrolling tbprobe adjustment loop
A bit tricky to identify, but in `apple-silicon` builds, specifying a value for
`SyzygyPath` could still lead to crashes at certain depths from a
SIGBUS/SIGSEGV.

This PR replaces the `std::count_if()` adjustment in `tbprobe.cpp`'s
`do_probe_table()` with an annotated handwritten loop, avoiding the clang/LTO
miscompilation behind the crash.

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

No functional change.
2026-04-15 19:05:14 +02:00
Shawn XuandJoost VandeVondele b63bd7b78e Fix assert
the assert checks for `bestThreadDecisive && newThreadDecisive`. However `newThreadDecisive` is not guaranteed at this point, leading to assertion failures. This PR rearranges the conditions to ensure correctness.

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

No functional change
2026-04-15 19:01:06 +02:00
Linmiao XuandDisservin bb4eb04a50 Don't store stand pat return value in TT
Passed non-regression STC:
https://tests.stockfishchess.org/tests/view/69d2d3de61a12cebe17ede38
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 68384 W: 17646 L: 17459 D: 33279
Ptnml(0-2): 200, 8058, 17496, 8231, 207

Passed non-regression LTC:
https://tests.stockfishchess.org/tests/view/69d4293433584dad27b3c8cb
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 37290 W: 9582 L: 9380 D: 18328
Ptnml(0-2): 18, 3915, 10579, 4113, 20

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

Bench: 2923401
2026-04-09 21:56:05 +02:00
Robert Nurnberg @ elitebookandDisservin 9db77822bd Simplify best thread selection
For some time now we can trust the threads' exact win/loss scores. This
allows for some simplification in the best thread selection code.

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

No functional change
2026-04-09 21:56:05 +02:00
FauziAkramandDisservin 5ae13d2bd4 Remove Redundant Branchless Execution
Passed STC non-reg:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 102272 W: 26553 L: 26411 D: 49308
Ptnml(0-2): 269, 11212, 28036, 11346, 273
https://tests.stockfishchess.org/tests/view/69d0f1c5e2b443cb2670b710

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

No functional change
2026-04-09 21:56:05 +02:00
Robert Nurnberg @ elitebookandDisservin d3a4587fe8 Simplify uci pv output logic
The uci pv suppression and PV roll-back logic in master is a bit
convoluted, which makes it hard to reason about the code. In fact,
subtle bugs that led to wrong mated-in scores in game play or a mismatch
between bestmove and first PV move were only recently fixed. Moreover,
in master the uci pv output through `pv()` is called in four different
places.

This PR proposes to simplify this logic. In this patch, the PV is sent
to the GUI from within `iterative_deepening()` only (a) for fail
highs/lows or (b) when an iteration for a root move is completed. All
other PV outputs are now handled by `start_searching()`, just before the
bestmove extraction. This easily ensures that bestmove (and ponder move)
will always be in sync with the final PV output.

The only noticeable change to master is for multi-threaded searches that
do not involve `limits.depth`. Here master would show both the PV from
the aborted search in main thread, as well as the new PV from the
selected best thread. This patch would only show the latter.

While at it, we also remove the requirement to finish at least a depth 1
search and simplify the logic around stalemates/checkmates at root and
in particular avoid any PVs that start with `Move::none()`.

Passed STC non-reg:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 72416 W: 18784 L: 18609 D: 35023
Ptnml(0-2): 200, 7762, 20127, 7901, 218
https://tests.stockfishchess.org/tests/view/69d3ef0c33584dad27b3c85a

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

No functional change
2026-04-09 21:56:05 +02:00
Carlos EsparzaandDisservin df01cb7ed3 Avoid branching before ValueList::push_back
Instead of checking whether a threat index is valid and then writing to
a vector if it isn't, we can instead always write to the buffer of the
vector, and only increase the size of the vector if the index is valid.

This saves some branch mispredictions.

passed STC:
https://tests.stockfishchess.org/tests/view/69ceb1689f7a7e3fdfc9a44b
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 205760 W: 53109 L: 52561 D: 100090
Ptnml(0-2): 603, 22552, 56076, 22992, 657

local speedtest shows
```
Result of 100 runs (cycles)
===========================
base (...ockfish.orig) =     296886  +/- 1645
test (...kfish.df0822) =     298862  +/- 1662
speedup %              =      +0.67  +/- 0.19
                         [95% CI; t-statistic]

p(speedup > 0)   =  1.0000
p(speedup > .5%) =  0.9562

CPU: 16 x Intel(R) Core(TM) Ultra 9 185H
Hyperthreading: on
```

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

No functional change
2026-04-09 21:56:05 +02:00
anematodeandDisservin ead7e650da Fix weird indexing bug
[Passed
STC](https://tests.stockfishchess.org/tests/live_elo/69cf6a5d1668971c9da23ae1)
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 51104 W: 13376 L: 13180 D: 24548
Ptnml(0-2): 134, 5555, 13963, 5781, 119

[Passed
LTC](https://tests.stockfishchess.org/tests/live_elo/69d00a7ee2b443cb2670b5c6)
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 101256 W: 25867 L: 25732 D: 49657
Ptnml(0-2): 59, 10423, 29520, 10576, 50

When processing a promotion we add/remove nonsensical threats, namely,
piece threats of pawns on the 1st or 8th rank. This is not only
inefficient but also seems to lead to an obscure bug during a
promotion–capture + `double_inc_update` that causes a lingering invalid
feature. Currently – as an artifact of the training process – these
parts of the net are filled with random values in [-1,1], which is why
there is a bench change.

@ces42 did a helpful analysis:

> checking bench with depth 17 actually shows that the bug in has been
there all the time since 8e5392d7 (when threat inputs was merged into
master)
> i.e. double_inc_update for ThreatFeatureSet has always been slightly
bugged

After this patch is applied we'll be able to better compress the net by
filling the invalid features with 0, w/o changing bench. I expect a
15%-ish size savings.

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

Bench: 2700393
2026-04-09 21:53:08 +02:00
FauziAkramandDisservin ef27b4db7b Using the already existing pawn_single_push_bb
Using the already existing pawn_single_push_bb helper which encapsulates
the exact same logic.

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

No functional change
2026-04-09 21:53:08 +02:00
Niklas FiekasandDisservin 20b61d2fd4 Fix shell escaping in misc.o rule
After 415f2ef1. Now works again with CXX paths like `A:\path\to\g++`
under MSYS2. The cache files are no longer read in the rule itself and
only used as markers for change detection.

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

No functional change
2026-04-09 21:53:08 +02:00
Linmiao XuandDisservin 93ba8fb35e CI: test for macOS g++ pretending to be clang++
Avoids compilation errors on macOS by ensuring flags specific to g++ are
applied to actual g++

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

No functional change
2026-04-09 21:53:08 +02:00
Linmiao XuandDisservin a42d328f21 Fix compilation errors on macOS
```
clang++: error: unknown argument: '-fno-ipa-cp-clone'
clang++: error: unknown argument: '-fno-ipa-cp-clone'
make[1]: *** [bitboard.o] Error 1
```

The flag is unsupported by Clang, which pretends to be GCC on macOS, so
only passing -fno-ipa-cp-clone to real GCC fixes macOS builds.

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

No functional change
2026-04-09 21:53:08 +02:00
anematodeandDisservin bb752eb2f6 Remove step in update_accumulator_refresh_cache
Passed simplification STC
https://tests.stockfishchess.org/tests/live_elo/69c9c050a54395a76133504c

LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 304544 W: 78502 L: 78574 D: 147468
Ptnml(0-2): 906, 33590, 83358, 33506, 912

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

No functional change
2026-04-09 21:53:08 +02:00
mstemberaandDisservin 969542e4f0 Simplify HalfKAv2_hm::write_indices()
https://tests.stockfishchess.org/tests/view/69bb1fafd7d60419badf31a3
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 116544 W: 30024 L: 29895 D: 56625
Ptnml(0-2): 317, 12875, 31729, 13064, 287

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

No functional change
2026-04-09 21:53:01 +02:00
FauziAkramandDisservin 82908e0fd6 Simplify mtg in time management
Passed Stc:
LLR: 3.05 (-2.94,2.94) <-1.75,0.25>
Total: 289088 W: 74727 L: 74773 D: 139588
Ptnml(0-2): 903, 30974, 80841, 30918, 908
https://tests.stockfishchess.org/tests/view/699d9093eaae015cd278eda3

Passed Ltc:
LLR: 3.02 (-2.94,2.94) <-1.75,0.25>
Total: 144438 W: 36859 L: 36766 D: 70813
Ptnml(0-2): 62, 13391, 45235, 13454, 77
https://tests.stockfishchess.org/tests/view/699f02913ece4c464328a264

Passed Sudden death:
LLR: 2.99 (-2.94,2.94) <-1.75,0.25>
Total: 53406 W: 13960 L: 13753 D: 25693
Ptnml(0-2): 265, 5848, 14253, 6089, 248
https://tests.stockfishchess.org/tests/view/69a47548a70d5f3736be6482

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

No functional change
2026-04-09 21:48:51 +02:00
FauziAkramandDisservin 19dec05602 Update a few outdated wrong comments
closes https://github.com/official-stockfish/Stockfish/pull/6525

No functional change
2026-04-09 21:48:40 +02:00
anematodeandDisservin 5eeca7392e Update NNUE architecture to SFNNv14 and net nn-7bf13f9655c8.nnue
[STC](https://tests.stockfishchess.org/tests/live_elo/69cb991bc025c305b7daa219)

LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 47520 W: 12558 L: 12219 D: 22743
Ptnml(0-2): 190, 5474, 12102, 5795, 199

[LTC](https://tests.stockfishchess.org/tests/live_elo/69cc6b42731dfb72d2e92128)

LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 123756 W: 31996 L: 31497 D: 60263
Ptnml(0-2): 81, 13512, 34221, 13955, 109

Adds features for pawns pushing against other pawns. For indexing, we
use the existing threats feature set by adding the forward square to the
squares threatened by a pawn. This threat is only enabled when another
pawn occupies that square. We then add appropriate logic changes in
`update_piece_threats` and `features/full_threats.cpp`.

The wonderful Ciekce (of Stormphrax) and peregrine (of Reckless) also
had similar ideas with adding forward pawn movements to TI, and I
appreciate their giving me motivation to figure out `nnue-pytorch` and
test it.

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

Bench: 2926703
2026-04-02 20:32:43 +02:00
Linmiao XuandDisservin 8a1b0f8b04 Reorder NNUE accumulator evals
Makes eval calls more cache-friendly on a hot path.

Hints of a speedup found locally:
```
Result of  30 runs
==================
base (...ockfish-base) =    1754124  +/- 2887
test (...h-eval-order) =    1757848  +/- 2412
diff                   =      +3724  +/- 1368

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

CPU: 16 x arm
Hyperthreading: off
```

Passed STC:
https://tests.stockfishchess.org/tests/view/69c84f3cf40d95b975597c21
LLR: 3.36 (-2.94,2.94) <0.00,2.00>
Total: 335840 W: 87022 L: 86257 D: 162561
Ptnml(0-2): 932, 36760, 91816, 37435, 977

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

No functional change
2026-04-02 20:32:43 +02:00
Linmiao XuandDisservin 171afd2b4d NEON: simplify updates in NNUE accumulator
Reduce # instructions using widening add/sub calls on AArch64.
Add shims for 32-bit ARM.

Passed non-regression STC:
https://tests.stockfishchess.org/tests/view/69c093d3f690a4b7f5fb0d6e
LLR: 5.15 (-2.94,2.94) <-1.75,0.25>
Total: 338624 W: 86931 L: 86853 D: 164840
Ptnml(0-2): 667, 35888, 96079, 36056, 622

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

No functional change
2026-04-02 20:32:43 +02:00
anematodeandDisservin c41c9bb973 Add -fno-ipa-cp-clone on GCC
Passed non-regression STC at
tests.stockfishchess.org/tests/view/69c9b8c3a54395a761335044 (set to
gainer bounds, *mea culpa*)

There's a major performance penalty when compiling the fish with GCC 16.
@Torom 's measurements (similar to mine, but more precise):

```
GCC 15 (master) vs. 16 (master)
sf_base =  2549174 +/-   2984 (95%)
sf_test =  2435456 +/-   2239 (95%)
diff    =  -113718 +/-   3599 (95%)
speedup = -4.46100% +/- 0.141% (95%)

GCC 15 (master) vs. 16 (patch)
sf_base =  2544107 +/-   3091 (95%)
sf_test =  2568837 +/-   3164 (95%)
diff    =    24729 +/-   4359 (95%)
speedup = 0.97204% +/- 0.171% (95%)
```

Based on looking at the disassembly + profiling data of the builds, the
root cause appears to be overly aggressive code duplication from
constant propagation of various functions especially in `search.cpp`.
The worst offender is `Worker::search`, which I think is being cloned
and optimized based on the value of `cutNode`. `perf stat` indicates
that the instruction cache miss rate goes up by ~50% on the GCC 16
build.

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

No functional change
2026-04-02 20:32:34 +02:00
anematodeandDisservin 347fcaa392 Stack allocate NNUE buffer
Passed simp STC

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 29632 W: 7772 L: 7552 D: 14308
Ptnml(0-2): 76, 3155, 8147, 3349,

Id expect there to be a small speedup (bc the compiler can skip some
stores) but i haven’t tried to measure it

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

No functional change
2026-04-02 20:30:44 +02:00
mstemberaandDisservin 7926f16ea7 Minor cleanups
closes https://github.com/official-stockfish/Stockfish/pull/6685

No functional change
2026-04-02 20:30:33 +02:00
anematodeandDisservin 8132dbcb5a split affine_transform on VNNI as well
```
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 184544 W: 47990 L: 47474 D: 89080
Ptnml(0-2): 551, 20238, 50206, 20698, 579
```

Torom measured

```
sf_base =  2538696 +/-   2915 (95%)
sf_test =  2546510 +/-   3011 (95%)
diff    =     7814 +/-   4146 (95%)
speedup = 0.30782% +/- 0.163% (95%)
```

I get something similar. The benefit would be larger if we ever decide
to further increase the L2 size I think

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

No functional change
2026-04-02 20:30:33 +02:00
Linmiao XuandDisservin f614ff90e2 Neon dotprod speedup in sparse-input affine transform
Also apply VNNI accumulator splitting strategy to NEON dotprod.

Speedup measured locally with profile-build, apple-silicon M3 Pro:
```
Result of  20 runs
==================
base (...kfish-master) =    1582485  +/- 12985
test (...parse-affine) =    1605204  +/- 13801
diff                   =     +22720  +/- 1212

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

CPU: 11 x arm
Hyperthreading: off
```

Passed STC:
https://tests.stockfishchess.org/tests/view/69c04c71f690a4b7f5fb0cde
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 80576 W: 20748 L: 20391 D: 39437
Ptnml(0-2): 161, 8472, 22658, 8843, 154

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

No functional change
2026-04-02 20:30:26 +02:00
Robert Nurnberg @ elitebookandDisservin b9f3273af1 Align ponder move and final PV output
In master for various reasons the given ponder move may get out of sync
with (the second move of) the last PV sent to the GUI:
1. If a ponder move is extracted from the TT despite bestmove leading to
a game ending draw.
2. If a ponder move is extracted from the TT from a fail high/low, since
after the ponder move extraction no new PV is sent to the GUI.
3. If `syzygy_extend_pv()` from within the call to `pv()` changes the PV
after the ponder move has been selected.
4. If the PV roll-back to protect mated-in scores differs in the second
move from the final PV sent to the GUI.

This PR keeps ponder move and the last printed PV in sync.

Fixes #6676.

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

No functional change
2026-04-02 20:30:12 +02:00
anematodeandDisservin d173a0655d Speedup splat_moves on avx512icl
STC
```
LLR: 5.45 (-2.94,2.94) <0.00,2.00>
Total: 612192 W: 158602 L: 157260 D: 296330
Ptnml(0-2): 1634, 67783, 166027, 68911, 1741
```

@Torom measured:
```
sf_base =  2380902 +/-   1016 (95%)
sf_test =  2391426 +/-   1065 (95%)
diff    =    10524 +/-   1336 (95%)
speedup = 0.44203% +/- 0.056% (95%)
```

I've verified that `_mm512_slli_epi16(v, 0)` gets optimized out in GCC
9+ and clang 4+. Added constants to types.h so that people messing
around with the layout of `Move` don't have to know about this part of
the code.

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

No functional change
2026-03-18 20:49:20 +01:00
FauziAkramandDisservin add173263d VVLTC Tune
Passed VVLTC with stc bounds:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 69810 W: 18119 L: 17814 D: 33877
Ptnml(0-2): 6, 6222, 22144, 6527, 6
https://tests.stockfishchess.org/tests/view/69b43f666c456d3a77a50a5d

Passed VVLTC with ltc bounds:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 52458 W: 13574 L: 13258 D: 25626
Ptnml(0-2): 5, 4632, 16636, 4954, 2
https://tests.stockfishchess.org/tests/view/69b16dfbd0c9228834e88e99

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

Bench: 3164843
2026-03-18 20:49:06 +01:00
Robert Nurnberg @ elitebookandDisservin 67a2c247d4 Improve multi-threaded go-mate searches
Ever since #5094 master only lets the main thread terminate `go mate`
searches, reverting the earlier improvement #1215.

This PR restores the old logic. So any thread that found a "mate in x"
can now stop the search.

To make this work robustly, we need to guard against inexact mate scores
in the best thread selection. In addition, in contrast to time limits,
the main thread may now not complete a d1 search for a mated-in
position.
In master an aborted d1 search may have a PV beginning with
`Move::none()`, in which case no thread selection is performed. See
#623. We fix this bug here by checking if `lastBestPV` is empty or not.
For interrupted d1 searches we now label mated-in scores as inexact.

While at it, we also simplify the logic for detecting if we can
terminate a go mate x search, using the fact that threads.stop can only
be false if we have a completed iteration with a valid score.

The PR has no effect on game play, but should slightly improve general
mate finding and speed up multi-threaded `go mate` searches.

We also add a corresponding matecheck run to the CI. This only involves
61 mates up to mate-in-2. Test runs with the first 50 or 100 mates from
`mates2000.epd` did at times not finish within 30 minutes on my fork or
in local tests, possibly due to search explosions for some mate-in-3
positions.

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

No functional change
2026-03-18 20:49:06 +01:00
Pieter te BrakeandDisservin e093339c2f Use existing function for removing and placing a piece.
Passed non-regression STC:
```
LLR: 3.33 (-2.94,2.94) <-1.75,0.25>
Total: 359712 W: 93077 L: 93175 D: 173460
Ptnml(0-2): 1088, 39816, 98144, 39722, 1086
```
https://tests.stockfishchess.org/tests/view/69af5e9a6b61ccc788710e31

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

No functional change
2026-03-18 20:49:06 +01:00
Tomasz SobczykandDisservin e38f5b2f53 Strict FEN parsing. Exit on setting invalid position via UCI.
fixes #6663, #6664, and a million others issues raised over the years.

This is similar to
https://github.com/official-stockfish/Stockfish/pull/4563/changes but
more conservative and errors are split between "Unsupported position"
and "Invalid FEN".

The FEN parser needs to be strict as a foundation for safety. It does
not specify much of the semantics, so this step is fairly simple. Parts
after the ep square are optional, however, since it's common, for
example in EPD notation.

Errors arising from positional semantics that were previously bucketed
under invalid FENs are now reported as "Unsupported position". Only
positions that are potentially problematic are designated as
unsupported. It is NOT guided by illegality of the position, but instead
by the ability of the engine to handle them correctly. This means that
some checks from the previous PR were removed.

std::exit is used instead of std::terminate so atexit handles will be
called.

Probably wise to run copilot on this or smth because I scribbled it
without much thought.

With these small changes and reduced, less controversial, scope I hope
this PR will finally make it and we will be done with these weekly
issues. I'll wait with putting it on fishtest until there's approval.

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

No functional change
2026-03-18 20:49:06 +01:00
Disservin 415f2ef11c Don't recompile misc.cpp on every run
alternative to https://github.com/official-stockfish/Stockfish/pull/6660

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

No functional change
2026-03-18 20:49:06 +01:00
MARLIN-ToolsandDisservin 3c04b5c429 Fix Depth 1 bug at very low time controls, some fishtesting workers, and delayed move senders like Arena.
Non-Regression STC:

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 98208 W: 25423 L: 25276 D: 47509
Ptnml(0-2): 271, 10713, 26994, 10850, 276
https://tests.stockfishchess.org/tests/view/69ad43c21d849c824c6afe82

-

Hell VVSTC (0.2+0.02)
LLR: 2.70 (-2.94,2.94) <0.00,2.00>
Total: 688 W: 660 L: 11 D: 17
Ptnml(0-2): 1, 0, 10, 15, 318
https://tests.stockfishchess.org/tests/view/69ae4bea1d849c824c6b00b0

-

Sudden Death (1+0)

LLR: 2.19 (-2.94,2.94) <-1.75,0.25>
Total: 538 W: 536 L: 0 D: 2
Ptnml(0-2): 0, 0, 0, 2, 267
https://tests.stockfishchess.org/tests/live_elo/69ae6c031d849c824c6b00dc

-

Sudden Death (5+0)

LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 22248 W: 6058 L: 5802 D: 10388
Ptnml(0-2): 214, 2420, 5583, 2710, 197
https://tests.stockfishchess.org/tests/view/69ae6dd01d849c824c6b00ee

-

Fixes #6639

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

No functional change
2026-03-18 20:49:06 +01:00
Ryan HirschandDisservin 8b49968386 Speed up update_accumulator_refresh_cache with AVX512ICL
Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 212960 W: 55550 L: 54991 D: 102419
Ptnml(0-2): 583, 23688, 57393, 24219, 597
https://tests.stockfishchess.org/tests/view/69ab916ccb31ee884aed62ea

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

No functional change
2026-03-18 20:49:06 +01:00
ZlomenyMesicandDisservin e20ef7ed12 Disable IIR and quiet shallow pruning in PV lines
Disable IIR and quiet shallow pruning in nodes that are part of the PV
line from the previous search iteration. This is done by storing the PV
in Worker and adding a followPV flag to Stack. The new flag may also be
used in other pruning techniques, allowing further improvement.

Passed STC:
```
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 63776 W: 16679 L: 16323 D: 30774
Ptnml(0-2): 169, 7441, 16377, 7667, 234
```
https://tests.stockfishchess.org/tests/view/69aad1a7d0f65de95886e289

Passed LTC:
```
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 87342 W: 22421 L: 22000 D: 42921
Ptnml(0-2): 40, 9443, 24299, 9834, 55
```
https://tests.stockfishchess.org/tests/view/69ab5993cb31ee884aed629d

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

Bench: 2434614
2026-03-18 20:49:06 +01:00
anematodeandJoost VandeVondele b3a810a1c4 Fix avx512icl update_piece_threats bug
Thanks to MinetaS for discovering this and finding the culprit commit,
specific to this architecture. 9f42980 was subtly incorrect, leading to
spurious wrong benches on avx512icl. Because this piece of code has twice been
the source of wrong benches, I also added a brief comment explaining why it
needs to be this way, and added a sample position to bench.

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

Bench: 2288704
2026-03-07 22:28:06 +01:00
Shawn XuandJoost VandeVondele 2907ee1a90 Requantize smallnet to nn-47fc8b7fff06.nnue
Passed Non-regression STC:
LLR: 3.01 (-2.94,2.94) <-1.75,0.25>
Total: 340384 W: 88165 L: 88274 D: 163945
Ptnml(0-2): 1145, 40248, 87571, 40027, 1201
https://tests.stockfishchess.org/tests/view/69a4c49ab4a714eaaa196bc0

Passed Non-regression LTC:
LLR: 2.97 (-2.94,2.94) <-1.75,0.25>
Total: 125922 W: 32222 L: 32106 D: 61594
Ptnml(0-2): 100, 13815, 35002, 13957, 87
https://tests.stockfishchess.org/tests/view/69a9d5f489704e42c5e3a35d

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

Bench: 2171643
2026-03-07 22:20:46 +01:00
8b6d8def30 Counter-Move History Continuity (CMHC)
Currently, the engine updates each level of the continuation history stack (ply -1, -2, -3, etc.) with fixed weights that are independent of one another. The idea behind CMHC is to scale the magnitude of these updates based on the consistency of the move's performance across the stack.
By tracking how often a move has historically performed well (positive history) within the current continuation context, we can adjust the update magnitude dynamically. Moves that demonstrate "continuity" (appearing as strong candidates across multiple historical contexts) receive more significant updates, while unproven or inconsistent moves are dampened.

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 103264 W: 26954 L: 26541 D: 49769
Ptnml(0-2): 338, 11910, 26728, 12313, 343
https://tests.stockfishchess.org/tests/view/69a81702fac54339cf435a87

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 47406 W: 12259 L: 11920 D: 23227
Ptnml(0-2): 22, 5052, 13237, 5349, 43
https://tests.stockfishchess.org/tests/view/69aab480bd35724e4b290498

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

Bench: 2356418

Co-Authored-By: Daniel Samek <samekdaniel@email.cz>
2026-03-07 22:16:22 +01:00
Shawn XuandJoost VandeVondele 868b63d421 Update main network to nn-9a0cc2a62c52.nnue
network with new hash encoding.

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

no functional change
2026-03-07 22:12:51 +01:00
Robert Nurnberg @ elitebookandJoost VandeVondele 82320c0e38 [CI] add multithreaded matetrack runs that simulate gameplay
closes https://github.com/official-stockfish/Stockfish/pull/6641

No functional change
2026-03-07 22:10:14 +01:00
maximmasiutinandJoost VandeVondele 702d4b8c9d Simplify attackers_to_exist function
test based on #6586 by maximmasiutin

https://tests.stockfishchess.org/tests/view/69977d58e2562aa5bc1e09c4
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 225056 W: 58208 L: 58195 D: 108653
Ptnml(0-2): 677, 25001, 61196, 24940, 714

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

No functional change
2026-02-28 12:10:50 +01:00
anematodeandJoost VandeVondele 4c0878cb0b skip setting threatByLesser[KING]
It doesn't make sense for a king to move to a square threatened by a lesser
piece, since that move would be illegal.

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

No functional change
2026-02-28 12:07:38 +01:00
mstemberaandJoost VandeVondele bc28ff15bd Simplify threat by lesser
STC https://tests.stockfishchess.org/tests/view/699da988eaae015cd278ede4
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 141184 W: 36647 L: 36541 D: 67996
Ptnml(0-2): 511, 16620, 36237, 16700, 524

LTC https://tests.stockfishchess.org/tests/view/699f4bee2be03365d5073c71
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 99852 W: 25463 L: 25322 D: 49067
Ptnml(0-2): 47, 10997, 27721, 11090, 71

Removes a constant and a branch(for the price of a subtract) and treats the
from and to squares symmetrically.

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

bench: 2460547
2026-02-28 12:06:39 +01:00
ByteBufandJoost VandeVondele b6769f101c CI: Fix typo in error message
closes https://github.com/official-stockfish/Stockfish/pull/6624

No functional change
2026-02-28 12:00:08 +01:00
Ryan HirschandJoost VandeVondele 0571e4e390 More NMP when improving
Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 89472 W: 23291 L: 22895 D: 43286
Ptnml(0-2): 317, 10389, 22942, 10757, 331
https://tests.stockfishchess.org/tests/view/699f070c3ece4c464328a26f

Passed LTC:
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 95880 W: 24537 L: 24098 D: 47245
Ptnml(0-2): 55, 10259, 26880, 10684, 62
https://tests.stockfishchess.org/tests/view/699fb9be44b9136df1165ded

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

bench: 2534375
2026-02-28 11:58:49 +01:00
Robert NurnbergandJoost VandeVondele 46ac9a7e6a prevent unproven mated-in scores in game play
This PR removes the variable threads.abortedSearch introduced in #4990 and
relies on threads.stop and completedDepth instead.

The logic in master is only guaranteed to work in single threaded search. For
multiple threads, as soon as threads.stop is set, some of the threads may abort
their search, and so their mated-in scores are not reliable.

Compared to master, this patch prevents unproven mated-in scores in these
multi-threaded scenarios:

    in game play (when time management is used)
    when the uci commands quit or stop are received
    when maximum depth is reached
    for go mate commands

The patch will change the bestmove in those very rare situations where the bug
occurs in master. This is because bestmove is taken from rootMoves[0].pv[0],
which will now no longer contain unproven mated-in PVs. In that sense the patch
is "functional". But of course, it does not change bench.

While at it, we also fix a bug in master that suppressed PV output for inexact
mated-in scores on receiving threads.stop. In cases where uciScore < score with
score not being a proven loss, and where the new bestmove was different from
the last completed iteration, this led to a bestmove output that did not match
the final PV (which was for an exact score).

Fixes #6293.

Fixes #6626.

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

No functional change
2026-02-28 11:55:03 +01:00
sscg13andJoost VandeVondele a6d055d7e2 Update NNUE architecture to SFNNv13 and net nn-5227780996d3.nnue
Since the introduction of Threat Inputs in SFNNv10 and its refinements, the
accumulator/L1 size has significantly decreased. This has made it more
computationally favorable to double the L2 size from 16 to 32.

Failed STC:
LLR: -2.98 (-2.94,2.94) <0.00,2.00>
Total: 189184 W: 49649 L: 49635 D: 89900
Ptnml(0-2): 881, 22479, 47812, 22585, 835
https://tests.stockfishchess.org/tests/view/69928ef7bfe62dc95a624d5c

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 37902 W: 9833 L: 9509 D: 18560
Ptnml(0-2): 35, 4074, 10408, 4400, 34
https://tests.stockfishchess.org/tests/view/69937936ff782f8eeef611e3

Passed VLTC SMP:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 20576 W: 5455 L: 5191 D: 9930
Ptnml(0-2): 6, 1837, 6338, 2101, 6
https://tests.stockfishchess.org/tests/view/6994df0586e4a32314116399

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

bench: 2396996
2026-02-18 21:46:57 +01:00