Pondering confusion

Discussion of chess software programming and technical issues.

Moderator: Ras

benvining
Posts: 30
Joined: Fri May 30, 2025 10:18 pm
Full name: Ben Vining

Pondering confusion

Post by benvining »

I'm trying to add pondering support to my UCI engine. I think I'm printing the ponder move correctly with the best move output. From what I understand, the GUI will send position/go commands to control the pondering. But I'm confused about what we're supposed to do when we get a "ponderhit" command: should this command abort the ponder search, play the ponder move on the internal board, and then start a new search...? Or does it just change a pondering flag to allow the (ongoing) ponder search to exit?
mar
Posts: 2659
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Pondering confusion

Post by mar »

yes, when you get a ponderhit you simply continue the ponder search as if it was a regular search now, you output the best move once time is up and that's it
benvining
Posts: 30
Joined: Fri May 30, 2025 10:18 pm
Full name: Ben Vining

Re: Pondering confusion

Post by benvining »

So when "go ponder" is received, the engine should start an infinite search, and then when "ponderhit" is received, it just switches from infinite to timed search? Should ponderhit also abort the ponder search, or just let it finish?
mar
Posts: 2659
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Pondering confusion

Post by mar »

what I do is that when go ponder is received, I basically start a normal search (allocating time normally),
but I don't output bestmove (yet), even if the search finishes (iterative deepening reaches max depth or time is up),
I still wait for stop or ponderhit.
so if I receive stop, I output bestmove and it was a pondermiss. if I receive a ponderhit and the search is still doing work, I let it finish and output bestmove as usual. if the search already finished I output bestmove.

of course you can do whatever you want - you can even start an infinite search, but then on ponderhit you have to set some time limit based on how much time has elapsed and what you'd normally allocate, seems a bit tricky.
you can experiment with a lot of things once you get it working
Lunar
Posts: 16
Joined: Wed May 21, 2025 12:32 pm
Full name: Patrick Hilhorst

Re: Pondering confusion

Post by Lunar »

mar wrote: Tue Jul 15, 2025 7:19 am even if the search finishes (iterative deepening reaches max depth or time is up)

How would your time be up when your opponent's clock is running?
benvining
Posts: 30
Joined: Fri May 30, 2025 10:18 pm
Full name: Ben Vining

Re: Pondering confusion

Post by benvining »

I think mar meant the time that was allocated for the search?
mar
Posts: 2659
Joined: Fri Nov 26, 2010 2:00 pm
Location: Czech Republic
Full name: Martin Sedlak

Re: Pondering confusion

Post by mar »

Lunar wrote: Tue Jul 15, 2025 8:13 pm How would your time be up when your opponent's clock is running?
right, you won't exit the ponder search until you receive a stop or finish the id loop, on ponderhit you simply clear the pondering flag which will enable the timeout check.

if the opponent thought for longer than you would, the timeout will trigger instantly after a ponder hit and the engine will reply immediately