1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-07-12 12:09:14 +00:00
BadFish/src
Joost VandeVondele 2cbc20e846 Correct and extend PV lines with decisive TB score
Currently (after #5407), SF has the property that any PV line with a decisive
TB score contains the corresponding TB position, with a score that correctly
identifies the depth at which TB are entered. The PV line that follows might
not preserve the game outcome, but can easily be verified and extended based on
TB information. This patch provides this functionality, simply extending the PV
lines on output, this doesn't affect search.

Indeed, if DTZ tables are available, search based PV lines that correspond to
decisive TB scores are verified to preserve game outcome, truncating the line
as needed. Subsequently, such PV lines are extended with a game outcome
preserving line until mate, as a possible continuation.  These lines are not
optimal mating lines, but are similar to what a user could produce on a website
like https://syzygy-tables.info/ clicking always the top ranked move, i.e.
minimizing or maximizing DTZ (with a simple tie-breaker for moves that have
identical DTZ), and are thus an just an illustration of how to game can be won.

A similar approach is already in established in
https://github.com/joergoster/Stockfish/tree/matefish2

This also contributes to addressing #5175 where SF can give an incorrect TB
win/loss for positions in TB with a movecounter that doesn't reflect optimal
play. While the full solution requires either TB generated differently, or a
search when ranking rootmoves, current SF will eventually find a draw in these
cases, in practice quite quickly, e.g.
`1kq5/q2r4/5K2/8/8/8/8/7Q w - - 96 1`
`8/8/6k1/3B4/3K4/4N3/8/8 w - - 54 106`

Gives the same results as master on an extended set of test positions from
9173d29c41
with the exception of the above mentioned fen where this commit improves.

With https://github.com/vondele/matetrack using 6men TB, all generated PVs verify:
```
Using ../Stockfish/src/stockfish.syzygyExtend on matetrack.epd with --nodes 1000000 --syzygyPath /chess/syzygy/3-4-5-6/WDL:/chess/syzygy/3-4-5-6/DTZ
Engine ID:     Stockfish dev-20240704-ff227954
Total FENs:    6555
Found mates:   3299
Best mates:    2582
Found TB wins: 568
```

As repeated DTZ probing could be slow a procedure (100ms+ on HDD, a few ms on
SSD), the extension is only done as long as the time taken is less than half
the `Move Overhead` parameter. For tournaments where these lines might be of
interest to the user, a suitable `Move Overhead` might be needed (e.g. TCEC has
1000ms already).

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

No functional change
2024-07-05 15:43:49 +02:00
..
incbin Cleanup comments 2023-12-31 19:54:27 +01:00
nnue Workaround the clang-format inconsistencies 2024-06-08 23:09:02 +02:00
syzygy Correct and extend PV lines with decisive TB score 2024-07-05 15:43:49 +02:00
benchmark.cpp Restore NPS output for Perft 2024-04-24 18:20:55 +02:00
benchmark.h Restore NPS output for Perft 2024-04-24 18:20:55 +02:00
bitboard.cpp Early Exit in Bitboards::sliding_attack() 2024-05-18 09:24:23 +02:00
bitboard.h Assorted cleanups 2024-02-11 19:52:00 +01:00
engine.cpp Move info strings once more 2024-07-03 13:39:31 +02:00
engine.h Move options into the engine 2024-06-12 09:17:04 +02:00
evaluate.cpp Give positional output more weight in nnue eval 2024-06-12 09:17:04 +02:00
evaluate.h Update default smallnet to nn-37f18f62d772.nnue 2024-06-01 19:59:07 +02:00
main.cpp Transform search output to engine callbacks 2024-04-05 21:03:58 +02:00
Makefile Change PGO type for clang 2024-06-08 23:05:56 +02:00
memory.cpp Add helpers for managing aligned memory 2024-06-03 23:11:59 +02:00
memory.h Add helpers for managing aligned memory 2024-06-03 23:11:59 +02:00
misc.cpp Implement dbg_extremes_of 2024-07-03 13:44:01 +02:00
misc.h Implement dbg_extremes_of 2024-07-03 13:44:01 +02:00
movegen.cpp Change the Move enum to a class 2024-01-04 15:51:04 +01:00
movegen.h Change the Move enum to a class 2024-01-04 15:51:04 +01:00
movepick.cpp Simplify continuation histories 2024-06-03 23:12:13 +02:00
movepick.h Add cmath header to movepick.h 2024-03-20 16:36:18 +01:00
numa.h NumaPolicy fixes and robustness improvements 2024-06-08 23:32:27 +02:00
perft.h Restore NPS output for Perft 2024-04-24 18:20:55 +02:00
position.cpp Limit has_game_cycle() to only upcoming repetition 2024-07-03 13:35:49 +02:00
position.h Limit has_game_cycle() to only upcoming repetition 2024-07-03 13:35:49 +02:00
score.cpp Fix wrong sign for 200 TB score 2024-04-13 22:05:19 +02:00
score.h Fix wrong sign for 200 TB score 2024-04-13 22:05:19 +02:00
search.cpp Correct and extend PV lines with decisive TB score 2024-07-05 15:43:49 +02:00
search.h Correct and extend PV lines with decisive TB score 2024-07-05 15:43:49 +02:00
thread.cpp Update clang-format to version 18 2024-06-05 21:41:43 +02:00
thread.h Fix typos in comments 2024-07-01 19:44:17 +02:00
thread_win32_osx.h Refactor NativeThread start_routine 2024-01-21 12:21:01 +01:00
timeman.cpp Simplify tm, removing faster 1st move and 1.13 extraTime. 2024-06-01 20:12:36 +02:00
timeman.h Simplify tm, removing faster 1st move and 1.13 extraTime. 2024-06-01 20:12:36 +02:00
tt.cpp Simplify away a useless TTEntry::read() 2024-07-01 19:50:32 +02:00
tt.h Simplify TT interface and avoid changing TT info 2024-06-12 09:17:04 +02:00
tune.cpp Move options into the engine 2024-06-12 09:17:04 +02:00
tune.h Move options into the engine 2024-06-12 09:17:04 +02:00
types.h Adjust lowest depth constants to the natural place 2024-06-03 23:20:02 +02:00
uci.cpp Move info strings once more 2024-07-03 13:39:31 +02:00
uci.h Fix printing of empty info strings. 2024-06-15 12:04:16 +02:00
ucioption.cpp Move options into the engine 2024-06-12 09:17:04 +02:00
ucioption.h Move options into the engine 2024-06-12 09:17:04 +02:00