Skip to content

Align ponder move and final PV output - #6679

Closed
robertnurnberg wants to merge 1 commit into
official-stockfish:masterfrom
robertnurnberg:is-draw
Closed

Align ponder move and final PV output#6679
robertnurnberg wants to merge 1 commit into
official-stockfish:masterfrom
robertnurnberg:is-draw

Conversation

@robertnurnberg

Copy link
Copy Markdown
Contributor

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.

No functional change.

@snicolet

Copy link
Copy Markdown
Member

Do you have a set of positions which could serve as test cases demonstrating the effect(s) of the patch?

@robertnurnberg

Copy link
Copy Markdown
Contributor Author

One example is given in the linked issue. Several more can be constructed with a script like this, using the fastchess version from Disservin/fastchess#997.

#!/bin/bash

count=0
while true; do
  ((count++))
  echo "Starting Run #$count..."

  ./fastchess -engine name=sf-dev1 cmd=./stockfish tc=1+0.01 \
  -engine name=sf-dev2 cmd=./stockfish tc=0.2+0.01 \
  -rounds 500 -concurrency -1 -openings file=UHO_Lichess_4852_v1.epd \
  format=epd -check-mate-pvs -check-ponder-pvs \
  -log level=info engine=true file=engine_log.txt append=false > fc_log.txt

  if grep -q "Warning" fc_log.txt; then
    echo "STOPPED: 'Warning' found in fc_log.txt during Run #$count"
    break
  else
    echo "Run #$count clean."
  fi
done

Sample log files: fc_log.txt.gz , engine_log_1m.txt.gz (first 1m lines)

> zgrep Warning fc_log.txt.gz | sed 's/- move.*//' | sort | uniq -c
      2 Warning; Pondermove does not match beginning of last PV 
    713 Warning; PV has length 1 despite ponder move output

The binary from this PR runs cleanly, without any warnings.

Directly looking at the code in master it is possible to reason about all the four cases mentioned in the PR description.

@vondele vondele added the bug label Mar 29, 2026
@Disservin Disservin added the to be merged Will be merged shortly label Apr 2, 2026
@Disservin Disservin closed this in b9f3273 Apr 2, 2026
@robertnurnberg
robertnurnberg deleted the is-draw branch April 2, 2026 19:50
ppigazzini pushed a commit to ppigazzini/zfish that referenced this pull request Jul 12, 2026
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 official-stockfish/Stockfish#6679

No functional change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug to be merged Will be merged shortly

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SF may emit a ponder move even if bestmove leads to a game ending draw

4 participants