Commit Graph
3158 Commits
Author SHA1 Message Date
ayushthepiro11andJoost VandeVondele 9d4090e826 Scale Null Move Pruning reduction dynamically based on evaluation margin
This patch introduces a dynamic scaling factor for Null Move Pruning (NMP) reductions. By scaling the reduction depth relative to the static evaluation margin against beta, the engine can afford more aggressive reductions in positions that are overwhelmingly favorable, optimizing CPU cycle utilization without compromising search integrity.

Passed STC:
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 85504 W: 22383 L: 22000 D: 41121
Ptnml(0-2): 225, 9855, 22218, 10220, 234
https://tests.stockfishchess.org/tests/view/6a4793daf97ff95f78795812

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 205800 W: 53879 L: 53224 D: 98697
Ptnml(0-2): 98, 21747, 58561, 22390, 104
https://tests.stockfishchess.org/tests/view/6a4b864ff97ff95f78795e52

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

Bench: 2513153
2026-07-10 20:19:02 +02:00
tonyandJoost VandeVondele 93ed4b53c4 Dynamic root score ema2
Improves calculation of root move score averages by dynamically calculating weight based on effort

Passed STC
https://tests.stockfishchess.org/tests/view/6a4ada97f97ff95f78795d5a
```
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 157248 W: 41003 L: 40515 D: 75730
Ptnml(0-2): 419, 18320, 40644, 18836, 405
```

Passed LTC
```
LLR: 3.03 (-2.94,2.94) <0.50,2.50>
Total: 197460 W: 51626 L: 50982 D: 94852
Ptnml(0-2): 85, 20849, 56237, 21455, 104
```

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

Bench: 2388656
2026-07-10 20:17:55 +02:00
Miloslav MacůrekandJoost VandeVondele 9700f6f206 Fix crash with UCI_LimitStrength and tablebases at the root
`Skill::pick_best()` assumes the root moves are sorted by score in descending order:

```cpp
Value topScore = rootMoves[0].score;
int   delta    = std::min(topScore - rootMoves[multiPV - 1].score, int(PawnValue));
```

That does not have to be so with Syzygy tablebases at the root, where the moves are ordered by `tbRank` instead. `rootMoves[0]` is then not the highest score and `delta` can go negative. Since `delta * (rng.rand<unsigned>() % int(weakness))` is evaluated as unsigned, a negative `delta` wraps to a large value and the `int(...)` cast overflows, so the `score + push >= maxScore` check never passes and `best` stays `Move::none()`. The caller

```cpp
std::swap(rootMoves[0],
          *std::find(rootMoves.begin(), rootMoves.end(),
                     skill.best ? skill.best : skill.pick_best(rootMoves, multiPV)));
```

then dereferences `end()`. The result is a crash, or sometimes `bestmove (none)` / an illegal move, in tablebase endgames when `UCI_LimitStrength` is set (or `Skill Level` is below 20).

The fix computes the score range over the candidate moves directly, so `delta` stays non-negative and a valid move is always returned.

**To reproduce**:
```
setoption name UCI_LimitStrength value true
setoption name UCI_Elo value 2900
setoption name SyzygyPath value <syzygy tablebases path>
position fen 8/8/8/4k3/8/8/3BKN2/8 b - - 0 1
go wtime 250 btime 250 winc 100 binc 100
```

You need to call the go command a couple of times before crash, after which is ends with

```
bestmove a1e5 ponder (none)
```

and on the next `go wtime 250 btime 250 winc 100 binc 100` it crashes printing:

```
info string Available processors: 0-31
info string Using 1 thread
info string NNUE evaluation using nn-af1339a6dea3.nnue (106MiB, (83248, 1024, 31, 32, 1))
info string Network replica 1: Shared memory.
```

Bench is unchanged, since this code only runs under `UCI_LimitStrength` / `Skill Level`.

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

No functional change
2026-07-10 20:17:23 +02:00
Robert NurnbergandJoost VandeVondele 48a9118251 Minor cleanups June 2026
In the spirit of previous such PRs, this PR proposes a collection of nonfunctional changes.

I am happy to incorporate changes from other devs, and revert some of the proposed changes if the maintainers ask me to.

Apart from trivial changes, the proposed changes so far include:

* A requested edit to `AUTHORS` and a resorting of all entries, following DIN 5007 for the treatment of any special characters.
* Exclude the two recent integer type renaming commits from git blame.
* Tightening of some static asserts in `history.h` to avoid overflows. (Note that rounding errors for floating point types could lead to the assert in `operator<<` triggering at run-time.)
* Re-instate the 0.5s maximal thinking time in case of a single legal move and reword the comment to make it clear that it should not be tuned.
* ~~A small refactoring of the network loading code thanks to @dubslow.~~
* A refactoring of the "dtz is dtm" code, also thanks to @dubslow.

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

No functional change
2026-07-10 20:12:38 +02:00
Adrian LadoniandJoost VandeVondele 7da31a1f1d Simplify futility multiplier
this patch simplifies the Value futility multiplier and changes pruning behaviour

passed stc: https://tests.stockfishchess.org/tests/view/6a462265f97ff95f78795600
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 38112 W: 10071 L: 9758 D: 18283
Ptnml(0-2): 88, 4341, 9903, 4618, 106

passed ltc: https://tests.stockfishchess.org/tests/view/6a470bc5f97ff95f7879576a
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 67482 W: 17738 L: 17363 D: 32381
Ptnml(0-2): 36, 7061, 19164, 7452, 28

patch rebased to latest master

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

Bench: 2353997
2026-07-06 11:33:03 +02:00
Daniel MonroeandJoost VandeVondele 3c858c19e6 Two small simplifications
Passed simplification STC
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 206368 W: 52592 L: 52560 D: 101216
Ptnml(0-2): 537, 24201, 53669, 24247, 530
https://tests.stockfishchess.org/tests/view/6a2c5ab00d5d4b19d0805326

Passed simplification LTC
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 109944 W: 27839 L: 27709 D: 54396
Ptnml(0-2): 61, 11938, 30844, 12068, 61
https://tests.stockfishchess.org/tests/view/6a2dc6e70d5d4b19d08053aa

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

Bench: 2767133
2026-06-25 13:10:08 +02:00
zungurandJoost VandeVondele 5b87bc48cd Remove unused search-layer APIs
The following have zero call sites repo-wide:

    SearchManager:🆔 never read or written (also never initialized, nor was it ever used).
    Search::Worker::elapsed_time(): never called. PV output uses tm.elapsed_time() (TimeManager) directly. (removed callers on 25361e5)
    MovePicker::begin()/end(): unused private accessors. (removed callers on 8c2d21f)

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

No functional change
2026-06-25 13:09:03 +02:00
Michael ChalyandJoost VandeVondele d64835051e Do more aggressive probCut when improving.
If improving is true reduce depth of probCut search by 1.
Passed STC:
https://tests.stockfishchess.org/tests/view/6a2a6ceb17167cbe7100a909
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 119136 W: 30591 L: 30158 D: 58387
Ptnml(0-2): 323, 13831, 30845, 14228, 341
Passed LTC:
https://tests.stockfishchess.org/tests/view/6a2d65a40d5d4b19d080537f
LLR: 2.96 (-2.94,2.94) <0.50,2.50>
Total: 186552 W: 47377 L: 46755 D: 92420
Ptnml(0-2): 89, 20047, 52395, 20643, 102

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

Bench: 2422062
2026-06-25 13:04:20 +02:00
Dalton HanawayandJoost VandeVondele 6f97594eda prefetch the TT entry as soon as the move is known
Worker::do_move computes the successor hash key via the new
Position::key_after(m) and prefetches the TT entry one full do_move
earlier than the existing prefetch in Position::do_move. key_after does
not model castling, en passant or promotion keys exactly; for rare
moves the prefetch lands on an unused line.

`key_after` has been around since 2014 (https://github.com/official-stockfish/Stockfish/commit/82d065b0) and was removed in (https://github.com/official-stockfish/Stockfish/pull/5770). Adding back `prefetch_key` helps in common, normal moves at the cost of extra compute.

Speedup (PGO vs PGO, interleaved paired bench, n=48 pairs, Apple M2
Pro / apple-silicon): +0.69% [0.47, 0.91]

Passed STC:
https://tests.stockfishchess.org/tests/view/6a291f8d7c758d82accea17f
LLR: 4.24 (-2.94,2.94) <0.00,2.00>
Total: 473504 W: 121250 L: 120228 D: 232026
Ptnml(0-2): 1112, 51137, 131251, 52121, 1131

No functional change

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

No functional change
2026-06-25 13:03:44 +02:00
Robert Nurnberg @ elitebookandDisservin 74a0a73715 Final fix for MultiPV mate PV corner cases
This PR fixes the remaining corner cases in the treatment of MultiPV
mated-in PVs, as well as an oversight in #6886. See the discussion in

In particular:
1. `previousScore` and `previousPV` can only be trusted, if that
   rootmove was indeed fully searched in the previous iteration.
2. A move beyond `pvIdx` (that was hence not fully searched) may have an
   exact loss score that cannot be trusted. So if a MultiPV search gets
   aborted while searching `pvIdx`, we mark all the following loss
   scores as bounds.
3. The forgotten mate logic also got broken in #6886, because the
   `previousPV` of the forgotten mate's bestmove can only be trusted if
   that move was fully searched in the previous iteration, something
   that is not guaranteed. So we now store both `lastBestMoveScore` and
   `lastBestMovePV`.

Here some scenarios for MultiPV = 8 that explain how master was broken:
1. Move A with an inexact mated-in-2 score from the previous iteration
   (so outside the top8 moves) gets flushed into the top8 moves for the
   current iteration, because the previous top8 move B is now scored as
   a mated-in-1. Hence we cannot trust `previousScore` or `previousPV`
   for move A, if the search gets aborted while it is being searched.
2. In the scenario above, move B has `Score != -VALUE_INFINITE` and a
   mated-in-1 score, which cannot be trusted as it was not fully
   searched.
3. Iteration N has bestmove A with mated-in-10, which gets recorded in
   `lastBestMoveScore` (renamed from `lastIterationScore`). Iteration 11
   forgets the mate and has bestmove B with a cp score, move A may have
   an incomplete PV, and may even have a non-mate score. Iteration 12
   gets aborted, and in trying to remember the forgotten mate, master
   recovers the `previousScore` and `previousPV` of move A, which may be
   neither mate nor complete.

Passed STC non-reg:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 69728 W: 17748 L: 17573 D: 34407
Ptnml(0-2): 143, 7571, 19274, 7720, 156
https://tests.stockfishchess.org/tests/view/6a2c40c60d5d4b19d08052f2

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

No functional change
2026-06-14 09:58:13 +02:00
anematodeandDisservin f9b002cf7d Share continuation history between threads
Passed 8th 5+0.05 https://tests.stockfishchess.org/tests/view/6a0bfdb46524d21ee79b879b
LLR: 2.94 (-2.94,2.94) <0.00,2.00>
Total: 23472 W: 6103 L: 5823 D: 11546
Ptnml(0-2): 26, 2501, 6403, 2779, 27

Passed 8th 20+0.2 https://tests.stockfishchess.org/tests/view/6a0c87196524d21ee79b885c
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 44692 W: 11640 L: 11319 D: 21733
Ptnml(0-2): 12, 4418, 13169, 4731, 16

Passed 16th 5+0.05 https://tests.stockfishchess.org/tests/view/6a20533f818cacc1db0ad32b
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 14720 W: 3910 L: 3642 D: 7168
Ptnml(0-2): 6, 1434, 4223, 1680, 17

Passed 64th 10+0.1 https://tests.stockfishchess.org/tests/view/6a20ae8e818cacc1db0ad369

LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 34096 W: 8889 L: 8607 D: 16600
Ptnml(0-2): 4, 2974, 10808, 3260, 2

Continuation history is fixed size so there's a much more false sharing and a larger speed loss here at high thread counts, unfortunately.

vondele's machine, 4x70

```
==== master ====
Average (over 3):  294528128
==== shared-conthist ====
Average (over 3):  282364217 (~4% slowdown)
```

my machine, 8x32
```
Nodes/second               : 243157385
Nodes/second               : 228374554 (~6% slowdown)
```

Evidently it still gains at 64th, but a few followup ideas to try get the speed back:
- Add padding in `PieceToHistory` stats so there's less false sharing.
- Subdivide continuation history more finely than shared correction history.
- Scramble the `PieceToHistory` indexing so there's less false sharing

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

No functional change
2026-06-14 09:58:13 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 7b37032885 Stop searching if we cannot find a better move
In a recent CCC event, Stockfish (probably through no fault of its own), lost some games on time when it was winning and when it had already found the move that delivers checkmate.

This patch stops the search when TM is active, and when mainthread can be certain that it is impossible to find a better move. That is if (i) it has found mate-in-1, (ii) it has found a mate-in-2 or (iii) it has found a mated-in-1.

patch:
```
position fen 5K2/8/2qk4/2nPp3/3r4/6B1/B7/3R4 w - e6
go wtime 100000000 winc 100000000
info string Available processors: 0-7
info string Using 1 thread
info string NNUE evaluation using nn-71d6d32cb962.nnue (106MiB, (83248, 1024, 31, 32, 1))
info string Network replica 1: Shared memory.
info depth 1 seldepth 3 multipv 1 score mate 1 nodes 30 nps 30000 hashfull 0 tbhits 0 time 1 pv d5e6
bestmove d5e6
```

master:
```
position fen 5K2/8/2qk4/2nPp3/3r4/6B1/B7/3R4 w - e6
go wtime 100000000 winc 100000000
info string Available processors: 0-7
info string Using 1 thread
info string NNUE evaluation using nn-71d6d32cb962.nnue (106MiB, (83248, 1024, 31, 32, 1))
info string Network replica 1: Shared memory.
info depth 1 seldepth 3 multipv 1 score mate 1 nodes 30 nps 15000 hashfull 0 tbhits 0 time 2 pv d5e6
<snip>
info depth 245 seldepth 2 multipv 1 score mate 1 nodes 5886 nps 367875 hashfull 0 tbhits 0 time 16 pv d5e6
bestmove d5e6
```

Note: In MultiPV analysis (extremely rare with TM active), we take the point of view that the user would like to continue to search until none of the PVs can be improved anymore. This means we only stop if the worst searched line is at least a mate-in-2, or if the best searched line is a mated-in-1.

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

No functional change
2026-06-10 12:42:01 +02:00
anematodeandJoost VandeVondele 0111d11e23 Add ability to disable performance-sensitive relaxed atomic operations at compile time
Adds a `RelaxedAtomic`  wrapper around either `T` or `std::atomic<T>` and `USE_SLOPPY_ATOMICS` preprocessor define. The intent of this flag is to allow easy disabling of atomics on WASM, where even relaxed atomics are expensive because all atomics have `seq_cst` semantics.

Passed non regression STC
LLR: 2.99 (-2.94,2.94) <-1.75,0.25>
Total: 50624 W: 12976 L: 12776 D: 24872
Ptnml(0-2): 112, 5445, 14005, 5631, 119
https://tests.stockfishchess.org/tests/view/6a1f690e818cacc1db0ad2c7

Passed non-regression STC SMP
 LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 163696 W: 41514 L: 41438 D: 80744
Ptnml(0-2): 162, 18272, 44904, 18348, 162
https://tests.stockfishchess.org/tests/view/6a21fb97351b79f679cc44b3

Using this class for the TT also allows us to remove the TSAN suppressions, since the UB is fixed.

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

No functional change
2026-06-09 21:52:29 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 1eff8b0389 Guarantee complete mate PVs in multiPV analysis
This PR introduces the additional `RootMove` attribute `previousPV` so that scores and PVs we send to the GUI in MultiPV analysis always match. This allows us in particular to extend our guarantee of exact mate (and TB win/loss) scores having a complete PV (leading to checkmate in the correct number of plies) to all PV lines. Recall that master fails here, since partially searched root moves may send to the GUI the previous score with the current/modified PV. See #6784.

The PR also uses the new attribute to extend the followPV logic to the analysis of sidelines, building on the idea in #6813 by @joergoster.

Passed non-reg STC:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 166880 W: 42357 L: 42282 D: 82241
Ptnml(0-2): 394, 18685, 45177, 18820, 364
https://tests.stockfishchess.org/tests/view/6a0dea55818cacc1db0abb6a

Failed non-reg LTC:
LLR: -2.97 (-2.94,2.94) <-1.75,0.25>
Total: 890520 W: 224168 L: 225282 D: 441070
Ptnml(0-2): 390, 91902, 261789, 90790, 389
https://tests.stockfishchess.org/tests/view/6a1143ad818cacc1db0ac14c

Opening as draft for discussion on how to proceed. In SinglePV analysis, the patch is completely nonfunctional. But it is maybe a (small?) slowdown because of the increased size of `RootMove`. I am not sure if there as an elegant way to enrich the class only for MultiPV analysis (but the switch can happen at any time through the UCI interface), or to mitigate the speed penalty in some other way.

A local speedup test shows only a small slowdown on my system (but still high error bars):
```
sf_base =  1156928 +/-   1459 (95%)
sf_test =  1155885 +/-   1283 (95%)
diff    =    -1043 +/-   1777 (95%)
speedup = -0.09021% +/- 0.154% (95%)
```

The PR also adds the new MultiPV mate PV correctness check to the CI.

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

No functional change
2026-06-09 19:36:14 +02:00
DisservinandJoost VandeVondele dd3e1c4a50 Consistent Integer Types
example of using, to avoid mixed usage of std::uint/std::int and uint/int...
```cpp
using u64 = std::uint64_t;
using u32 = std::uint32_t;
using u16 = std::uint16_t;
using u8  = std::uint8_t;

using i64 = std::int64_t;
using i32 = std::int32_t;
using i16 = std::int16_t;
using i8  = std::int8_t;

using usize = std::size_t;
using isize = std::ptrdiff_t;

#if defined(__GNUC__) && defined(IS_64BIT)
__extension__ using u128 = unsigned __int128;
__extension__ using i128 = signed __int128;
#endif
```

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

No functional change
2026-06-08 19:54:33 +02:00
FauziAkramandJoost VandeVondele e4a635486a Simplify margin formula
Passed STC non-reg:
LLR: 2.93 (-2.94,2.94) <-1.75,0.25>
Total: 46944 W: 11934 L: 11730 D: 23280
Ptnml(0-2): 95, 5403, 12273, 5605, 96
https://tests.stockfishchess.org/tests/view/6a0b018d6524d21ee79b8680

Passed LTC non-reg:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 535980 W: 135398 L: 135702 D: 264880
Ptnml(0-2): 241, 58385, 151023, 58119, 222
https://tests.stockfishchess.org/tests/view/6a0c3ab86524d21ee79b87f2

Passed VLTC non-reg:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 126632 W: 32068 L: 31961 D: 62603
Ptnml(0-2): 14, 12466, 38244, 12583, 9
https://tests.stockfishchess.org/tests/view/6a1ac130818cacc1db0ad03c

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

Bench: 3493826
2026-06-06 10:15:00 +02:00
AdrianandJoost VandeVondele 73826352d4 Simplify quiet history update expression
This patch simplifies the quiet history update expression in search.cpp.

The change is behaviour‑identical and removes unnecessary complexity from
the update_quiet_histories call.

Passed STC (non‑regression):
https://tests.stockfishchess.org/tests/view/6a14367b818cacc1db0ac7c3
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 52224 W: 13338 L: 13135 D: 25751
Ptnml(0-2): 118, 6065, 13557, 6240, 132

Passed LTC (non‑regression):
https://tests.stockfishchess.org/tests/view/6a155046818cacc1db0ac94d
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 136812 W: 34689 L: 34586 D: 67537
Ptnml(0-2): 51, 14770, 38668, 14859, 58

Both STC and LTC passed. Patch rebased to latest master.

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

Bench: 2549662
2026-06-06 10:12:36 +02:00
Stefan GeschwentnerandJoost VandeVondele 645b636dfa Tweak best move history updates.
If not at an PV node, scale history bonus for the found best move up proportionally to the count of the other moves searched.

Passed STC:
LLR: 2.96 (-2.94,2.94) <0.00,2.00>
Total: 219712 W: 56104 L: 55525 D: 108083
Ptnml(0-2): 565, 25482, 57188, 26051, 570
https://tests.stockfishchess.org/tests/view/6a1306fb818cacc1db0ac5b7

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 53988 W: 13851 L: 13498 D: 26639
Ptnml(0-2): 22, 5779, 15051, 6108, 34
https://tests.stockfishchess.org/tests/view/6a1b557e818cacc1db0ad0b8

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

Bench: 2935474
2026-06-06 10:05:50 +02:00
FauziAkramandJoost VandeVondele b1053e60b7 Simplify Internal Iterative Reductions (IIR) Condition
Passed STC non-reg:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 75840 W: 19367 L: 19192 D: 37281
Ptnml(0-2): 186, 8837, 19710, 8990, 197
https://tests.stockfishchess.org/tests/view/6a0b02ba6524d21ee79b8685

Passed LTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 166920 W: 42039 L: 41967 D: 82914
Ptnml(0-2): 78, 18155, 46919, 18233, 75
https://tests.stockfishchess.org/tests/view/6a0c98fb6524d21ee79b8875

Passed VTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 46390 W: 11914 L: 11729 D: 22747
Ptnml(0-2): 8, 4543, 13911, 4722, 11
https://tests.stockfishchess.org/tests/view/6a143877818cacc1db0ac7c5

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

Bench: 2814421
2026-05-29 19:06:38 +02:00
FauziAkramandJoost VandeVondele 94984fe5cb Simplify Mated Conditions in Iterative Deepening
Follow-up to #6785

After completing an iteration, the engine verifies if a "mate in x" condition is met to stop searching. Currently, it checks is_mate() and is_mated() independently using two separate bulky logic branches. However, VALUE_MATE equals 32000, so both a mate (e.g., 31998) and a mated score (e.g., -31998) satisfy VALUE_MATE - std::abs(score) == 2. By utilizing is_mate_or_mated() and applying std::abs(), we mathematically combine these checks into a single concise expression.

Can someone please help run a matetrack with a --mate 100 limit for this?

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

No functional change
2026-05-19 18:41:36 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 78d8f09bc8 Revert f8aa78e0a7
The two links given in the PR description for #6826 are not for the same code changes. The code that was eventually committed passed LTC non-reg, but not STC non-reg. However, it was a meaningful code change and so would have needed gainer bounds.

See https://tests.stockfishchess.org/tests/view/69fa69c83a3c3e525bb2b645 and https://tests.stockfishchess.org/tests/view/6a00a2549392f0c317214085.

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

Bench: 2259945
2026-05-19 18:41:00 +02:00
DubslowandJoost VandeVondele 319d61effd Penalize TTEs whose inexact value mismatches the current window
Credit shared with @xu-shawn, who has done much of the work to instrument the search and investigate search explosions and endgame paralysis: https://github.com/official-stockfish/Stockfish/issues/6742#issuecomment-4386174472

This patch is a natural result of that commentary. It can also be seen as a refinement of more generalized secondary aging.

Passed STC: https://tests.stockfishchess.org/tests/view/69fb18e8c91f9625ce325427
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 434784 W: 111417 L: 110528 D: 212839
Ptnml(0-2): 1089, 50675, 112949, 51616, 1063

Passed LTC: https://tests.stockfishchess.org/tests/view/6a0379588d9bd4cd7cd68edf
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 81018 W: 20558 L: 20154 D: 40306
Ptnml(0-2): 35, 8554, 22939, 8934, 47

VVLTC *reversion*: https://tests.stockfishchess.org/tests/view/6a0622538d9bd4cd7cd69340
Ptnml(0-2): 2, 5159, 18107, 5050, 0
LLR: -2.94 <0.50,2.50>
LLR: -2.47 <0.00,2.00>
LLR: -2.24 <-0.25,1.75>

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

Bench: 2676789
2026-05-19 18:38:07 +02:00
FauziAkramandJoost VandeVondele f8aa78e0a7 Simplify ttMove reduction formula
Passed STC non-reg:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 110720 W: 28313 L: 28180 D: 54227
Ptnml(0-2): 230, 12259, 30279, 12332, 260
https://tests.stockfishchess.org/tests/view/69fa69c83a3c3e525bb2b645

Passed LTC non-reg:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 307728 W: 77955 L: 78027 D: 151746
Ptnml(0-2): 138, 33481, 86698, 33409, 138
https://tests.stockfishchess.org/tests/view/6a00a2549392f0c317214085

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

Bench: 2559757
2026-05-17 20:51:07 +02:00
anematodeandJoost VandeVondele 91736f7b4f Compute correction_value before TT lookup
Passed single-threaded STC with 128MB hash
https://tests.stockfishchess.org/tests/view/6a04a6348d9bd4cd7cd69124
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 103808 W: 26400 L: 26007 D: 51401
Ptnml(0-2): 205, 11212, 28711, 11537, 239

Passed standard SMP STC
https://tests.stockfishchess.org/tests/view/6a054f528d9bd4cd7cd69225
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 80392 W: 20580 L: 20221 D: 39591
Ptnml(0-2): 79, 8872, 21942, 9217, 86

Entering `do_move`, `correction_value` and the TT lookup are always done together, but the TT lookup happens first. Swapping the order allows the execution of `correction_value` to overlap with the in-flight TT prefetch.

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

No functional change
2026-05-17 20:48:12 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 1cebdafc14 Help aborted searches remember mate scores
This patch improves mate finding results by protecting mate scores from being forgotten in a later iteration. This applies especially to aborted searches, but also to completed iterations in e.g. `go depth` scenarios. The only visible change to the user is the final UCI info line.

The case of TB wins/losses was excluded from this patch on purpose. The reason is that in some corner cases related to rounding in some DTZ Syzygy EGTBs, later searches may turn a TB loss into a draw, for example. See #5175 and the example
```
info depth 5 seldepth 5 multipv 1 score cp -20000 nodes 122 nps 8714 hashfull 0 tbhits 26 time 14 pv h1b1 a7b6 f6e5 b6b1 e5f4 c8c3 f4g5 d7h7 g5f4 b1f5 f4f5 c3e5 f5g6 e5f4 g6h7 f4g5 h7h8 b8c7 h8h7 c7d6 h7h8 d6e5 h8h7 e5f6 h7h8 g5g7
info depth 6 seldepth 9 multipv 1 score cp 0 nodes 255 nps 18214 hashfull 0 tbhits 26 time 14 pv h1h2 d7d6 f6g5 a7e7
```
from #5414.

Matetrack for patch:
```
Using ./stockfish on matetrack.epd with --nodes 1000000
Engine ID:     Stockfish dev-20260510-dbbc3ed1
Total FENs:    6554
Found mates:   3054
Best mates:    2224
```
This is slightly more/equal compared to master (3040 and 2224), see https://github.com/vondele/matetrack/blob/faf7cf3be95ab7dfdcde6e035de28a30887cd8a5/matetrack1000000.csv#L4368.

Passed STC non-reg:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 108224 W: 27565 L: 27429 D: 53230
Ptnml(0-2): 212, 11755, 30064, 11847, 234
https://tests.stockfishchess.org/tests/view/6a00899e9392f0c31721406c

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

No functional change
2026-05-17 20:44:44 +02:00
FauziAkramandJoost VandeVondele a12dc6cc1f VVLTC parameter's tune
Passed 1st VVLTC test with STC-bounds:
LLR: 2.95 (-2.94,2.94) <0.00,2.00>
Total: 78172 W: 20207 L: 19894 D: 38071
Ptnml(0-2): 2, 6871, 25032, 7174, 7
https://tests.stockfishchess.org/tests/view/69fa262f3a3c3e525bb2b5e7

Passed 2nd VVLTC test with LTC-bounds:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 44360 W: 11624 L: 11322 D: 21414
Ptnml(0-2): 0, 3931, 14022, 4221, 6
https://tests.stockfishchess.org/tests/view/69f8b30d3a3c3e525bb2b3d9

STC estimate test:
Elo: -1.50 ± 1.5 (95%) LOS: 2.3%
Total: 55742 W: 14169 L: 14409 D: 27164
Ptnml(0-2): 143, 6697, 14452, 6415, 164
nElo: -2.95 ± 2.9 (95%) PairsRatio: 0.96
https://tests.stockfishchess.org/tests/view/69fef06c9392f0c317213dca

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

Bench: 2619968
2026-05-10 11:49:00 +02:00
Jörg OsterandJoost VandeVondele 944bee7117 Fix calculation of searched nodes (effort)
by moving it back to its original place right before making the move. See the original patch https://github.com/official-stockfish/Stockfish/commit/bf2c7306ac7f83200ba4d894867e3c0c78c0802c

Only functional with active time-management.

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

No functional change
2026-05-10 11:47:50 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele fcbd160d26 [refactor] Add helper functions and simplify thread selection
I found these changes useful and natural when working on a patch to improve mate reporting. I can revert some of the changes if maintainers would prefer that. E.g. I am not sure whether `unset_bound_flags()` is worth defining.

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

No functional change
2026-05-10 11:43:53 +02:00
anematodeandJoost VandeVondele ab8f901d25 Remove small net
Failed VVLTC non-regression
https://tests.stockfishchess.org/tests/view/69d562b84088e069540a2288
LLR: -2.96 (-2.94,2.94) <-1.75,0.25>
Total: 386998 W: 99181 L: 99760 D: 188057
Ptnml(0-2): 35, 35792, 122429, 35203, 40

Failed STC non-regression
https://tests.stockfishchess.org/tests/view/69f3c6601e5788938e86a99e
LLR: -2.93 (-2.94,2.94) <-1.75,0.25>
Total: 33696 W: 8492 L: 8795 D: 16409
Ptnml(0-2): 124, 4209, 8504, 3868, 143

Many thanks to Dubslow, Torom, ces42, Shawn, vondele, Disservin and others for discussion.

## Summary

The venerable small net has been around for quite some time now, and while the big net architecture has substantially advanced with TI, the small net has stayed with plain HalfKA. It therefore presents a few burdens: multiple net architectures to maintain, multiple nets to train, and a whole lot of templates to deal with the variable L1 size.

Locally I measure a slowdown of -2.5% in NPS with this branch – and it's probably more on non-AVX512 architectures – but a pure slowdown of that magnitude would lead to more dramatic losses (even at VVLTC) than exhibited in the above tests, suggesting that the small net's lower eval quality is deleterious.

Bonus: Shawn found this interesting PGN among the VVLTC games: https://lichess.org/study/hvo8jflc/OeTOityv  `master` seems to misevaluate the fortress because all positions go to small net (the material difference is larger than the threshold).

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

Bench: 2877007
2026-05-04 08:32:42 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 7e754e17dd Simplify away completedDepth
Recent changes to this part of the code mean that the variable `completedDepth` is no longer neeeded. The only *functional* part of this patch is the effect on the thread voting formula. Basically, compared to master this patch raises the depth weight in the formula uniformly by 1. For very, very low depths this may have a tiny effect on thread selection compared to master. But in general we expect this patch to have no effect on game play at STC and LTC.

Passed STC SMP non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 284808 W: 72944 L: 72994 D: 138870
Ptnml(0-2): 351, 32192, 77370, 32138, 353
https://tests.stockfishchess.org/tests/view/69eddd011e5788938e86a075

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

No functional change
2026-05-04 08:31:44 +02:00
FauziAkramandJoost VandeVondele 4055a9fb27 Remove the limit from the formula
Passed STC:
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 364768 W: 94115 L: 94250 D: 176403
Ptnml(0-2): 1101, 40158, 99989, 40047, 1089
https://tests.stockfishchess.org/tests/view/69e7ca530e9667dd5a7655a7

Passed LTC:
LLR: 2.94 (-2.94,2.94) <-1.75,0.25>
Total: 146382 W: 37335 L: 37247 D: 71800
Ptnml(0-2): 64, 14682, 43630, 14732, 83
https://tests.stockfishchess.org/tests/view/69eeaf551e5788938e86a1e6

Passed VLTC:
LLR: 3.00 (-2.94,2.94) <-1.75,0.25>
Total: 48308 W: 12350 L: 12172 D: 23786
Ptnml(0-2): 4, 4303, 15362, 4481, 4
https://tests.stockfishchess.org/tests/view/69f25adb1e5788938e86a794

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

No functional change
2026-05-04 08:31:25 +02:00
3e3e976fdf [bugfix] Respect bound flags for searched moves in multiPV analysis
Master in `pv()` incorrectly assumes that any root move with `i != pvIdx` has an exact score. This can lead to the suppression of bound flags for (a) root moves that have been partially searched in an iteration but do not end up to be best move, or (b) when an aborted search for `pvIdx > 0` leads to a new best move. This latter case is the cause for issue #6783.

Fixes #6783.

The bug in its incarnation (a) was independently discovered by @ciekce a couple of weeks ago, and we have jointly discussed a patch that fixes it. He is therefore a co-author of the bugfix part of this patch.

While at it, we also fix three minor oversights in the PV roll-back for aborted searches with a loss score:
* We only roll back the PV if the aborted search would report an exact score.
* Master inadvertently may have reported a bound for the rolled-back score+PV.
* We ensure a final UCI info line with the correct search depth and searched nodes statistics etc.

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

No functional change

Co-Authored-By: Ciekce <44617491+Ciekce@users.noreply.github.com>
2026-05-04 08:31:06 +02:00
FauziAkramandJoost VandeVondele 2be0b2cdb4 Change ttmove reduction logic, and values
Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 38112 W: 10024 L: 9708 D: 18380
Ptnml(0-2): 104, 4365, 9830, 4625, 132
https://tests.stockfishchess.org/tests/view/69dd25a33ca80bdf151d4b33

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 256926 W: 65744 L: 64977 D: 126205
Ptnml(0-2): 126, 27919, 71612, 28674, 132
https://tests.stockfishchess.org/tests/view/69de48645c67bee7d241ff4e

Passed VLTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 174386 W: 44640 L: 44578 D: 85168
Ptnml(0-2): 26, 17847, 51384, 17911, 25
https://tests.stockfishchess.org/tests/view/69e767370e9667dd5a76551b

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

Bench: 2788824
2026-05-04 08:30:47 +02:00
FauziAkramandJoost VandeVondele 7bd32a51f5 Replacing the futility margin static value with a continuous transition
Smooth the futility margin by interpolating the multiplier based on depth, replacing the previous static value with a continuous transition between depth 1 and 10.

Passed STC:
LLR: 2.93 (-2.94,2.94) <0.00,2.00>
Total: 208448 W: 53891 L: 53324 D: 101233
Ptnml(0-2): 629, 24426, 53574, 24939, 656
https://tests.stockfishchess.org/tests/view/69e232206f344a19176002f3

Passed LTC:
LLR: 2.94 (-2.94,2.94) <0.50,2.50>
Total: 208938 W: 53432 L: 52765 D: 102741
Ptnml(0-2): 105, 22531, 58550, 23158, 125
https://tests.stockfishchess.org/tests/view/69e8b5d00e9667dd5a7656c6

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

Bench: 2661424
2026-05-04 08:30:28 +02:00
FauziAkramandJoost VandeVondele c787509663 Simplify time management reduction logic
Simplify the time management reduction logic by replacing the previous sigmoid
function with the linear interpolate function introduced in #6729 , resulting
in a cleaner and more efficient calculation of move stability that avoids
unnecessary exponential operations.

Passed STC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 161856 W: 41933 L: 41852 D: 78071
Ptnml(0-2): 418, 18137, 43792, 18108, 473
https://tests.stockfishchess.org/tests/view/69e117a46f344a1917600148

Passed LTC non-reg:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 108726 W: 27819 L: 27692 D: 53215
Ptnml(0-2): 59, 11084, 31942, 11227, 51
https://tests.stockfishchess.org/tests/view/69e563c00e9667dd5a7652ac

This is a follow-up for #6091  #6729

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

No functional change
2026-04-26 09:35:37 +02:00
Robert Nurnberg @ elitebookandJoost VandeVondele 86853a60ce [bugfix] Send correct search depth in final UCI info line
For quite some time SF has reported a too low final search depth in rare cases
(in multi-threaded search if a non-main thread was selected). Unfortunately,
the recent refactoring in #6704 means that this now happens for almost every
stopped search.

This PR fixes this issue, which was first spotted and reported by joergoster,
by ensuring that `rootDepth` always holds the last depth for which a search was
started.

Fixes #6756.

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

No functional change.
2026-04-26 09:28:54 +02:00
Robert NurnbergandJoost VandeVondele 50e8ff1e23 multiPV: protect mated-ins and allow thread selection
This PR is a replacement for #6652 and takes into account the changes made to this part of the code since then.

In multiPV analysis master may suppress genuine proven mated-in scores, if the iteration for a secondary PV line is aborted. In very rare cases, it may also evict a proven mated-in score from the best PV line with a score from an incomplete iteration of a secondary PV line. This PR avoids both.

In addition, we allow best thread selection in multithreaded multiPV searches. This was originally disabled in #524.

Single PV searches are not affected by this patch at all.

Fixes #6642.

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

No functional change.
2026-04-26 09:24:34 +02:00
FauziAkramandJoost VandeVondele ed651aab54 Replacing std::clamp with std::min
No functional change

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

No functional change
2026-04-20 17:45:03 +02:00
FauziAkramandJoost VandeVondele c66acdac99 Restructure Futility pruning
to a simpler and cleaner version

Passed non-reg test:
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 175648 W: 45156 L: 45091 D: 85401
Ptnml(0-2): 459, 19228, 48383, 19297, 457
https://tests.stockfishchess.org/tests/view/69d8d9263ca80bdf151d454a

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

No functional change
2026-04-19 07:21:27 +02:00
Maxim MasiutinandJoost VandeVondele 40ac93b8f8 Fix MultiArray::at(); use operator[] on hot paths
Fix MultiArray::at() which was marked noexcept despite delegating to
std::array::at() that throws on out-of-range. Per review feedback, at() now
keeps standard bounds-checking semantics (only noexcept removed), and
operator[] gains an assert for debug-mode safety.

All eight correction history lookups in search.cpp (correction_value and
update_correction_history) are switched from .at(us) to [us].

Passed STC:
https://tests.stockfishchess.org/tests/view/69de7a735c67bee7d241ff92
LLR: 2.96 (-2.94,2.94) <-1.75,0.25>
Total: 77536 W: 20031 L: 19860 D: 37645
Ptnml(0-2): 221, 8411, 21338, 8572, 226

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

No functional change
2026-04-19 07:19:23 +02:00
FauziAkramandJoost VandeVondele 95f3680080 Replace constant LMR history divisor with depth-based array
Passed STC:
LLR: 2.97 (-2.94,2.94) <0.00,2.00>
Total: 677344 W: 175301 L: 174041 D: 328002
Ptnml(0-2): 2018, 79669, 174166, 80673, 2146
https://tests.stockfishchess.org/tests/view/69cfae021668971c9da23b80

Passed LTC:
LLR: 2.95 (-2.94,2.94) <0.50,2.50>
Total: 46470 W: 11988 L: 11651 D: 22831
Ptnml(0-2): 37, 4877, 13055, 5244, 22
https://tests.stockfishchess.org/tests/view/69dcd13c3ca80bdf151d4ab5

Passed VLTC (non-reg.):
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 58986 W: 15120 L: 14947 D: 28919
Ptnml(0-2): 7, 5835, 17636, 6008, 7
https://tests.stockfishchess.org/tests/view/69debc6c5c67bee7d241ffe9

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

Bench: 2723949
2026-04-19 07:15:43 +02:00
DisservinandJoost VandeVondele 45711fceb4 Add PVMoves Struct
Use a dedicated struct for keeping track of the pv moves.

anematode pointed out that we can use the ValueList for this as well, left that open for a future patch.

Passed Non Regression
https://tests.stockfishchess.org/tests/view/69d399cfec2dc6794cf18376
LLR: 2.95 (-2.94,2.94) <-1.75,0.25>
Total: 267264 W: 68895 L: 68927 D: 129442
Ptnml(0-2): 790, 29238, 73566, 29290, 748

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

No functional change
2026-04-15 20:30:00 +02:00
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
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
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
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
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
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 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