Pondering confusion

Discussion of chess software programming and technical issues.

Moderator: Ras

benvining
Posts: 29
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: 2658
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: 29
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: 2658
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