Page 1 of 1

"ping" and pondering

PostPosted: 18 Nov 2018, 23:13
by jdart
The CEGT protocol description says re "ping":

In this command, N is a decimal number. When you receive the command, reply by sending the string pong N, where N is the same number you received. Important: You must not reply to a "ping" command until you have finished executing all commands that you received before it. Pondering does not count; if you receive a ping while pondering, you should reply immediately and continue pondering. Because of the way xboard uses the ping command, if you implement the other commands in this protocol, you should never see a "ping" command when it is your move; however, if you do, you must not send the "pong" reply to xboard until after you send your move. For example, xboard may send "?" immediately followed by "ping". If you implement the "?" command, you will have moved by the time you see the subsequent ping command. Similarly, xboard may send a sequence like "force", "new", "ping". You must not send the pong response until after you have finished executing the "new" command and are ready for the new game to start.

I have been interpreting this as meaning ping during ponder always should be immediately responded to. However, I am encountering an issue when the UI sends a "result" command, due to an adjudicated draw for example. Here (the UI is cutechess-cli) I see "force", "result" and then "ping" sent to the engine. The engine currently sends "pong" right away if it was pondering. However, it appears this is incorrect: what happens is it then gets a bunch of commands to start a new game, most of which arrive while the ponder search is still happening (because "result" began the process of terminating the search but it is not terminated yet). And it really isn't ready to process those. So it seems to me it should terminate the search when force and/or result are received, and then send the "pong" command after search termination. So in other words, "reply immediately and continue pondering" doesn't apply if you have already received a ponder-terminating command prior to "ping."

Re: "ping" and pondering

PostPosted: 19 Nov 2018, 22:40
by Brian Richardson
Not sure if this helps, but Tinker stops searching (including pondering) on any "force", "stop", or "exit" command.

Re: "ping" and pondering

PostPosted: 20 Nov 2018, 15:40
by jdart
stops searching (including pondering) on any "force", "stop", or "exit" command

I do too but with mulithreading especially there can be a delay between determining to stop searching and actually stopping all threads and finishing up the search.


Re: "ping" and pondering

PostPosted: 24 Nov 2018, 11:50
by H.G.Muller
I guess the description is a bit ambiguous: "while pondering" here means "when according to all commands it has received so far it should be pondering". In the mentioned case the "force" command terminates the pondering, so the "ping" is not received "while pondering".

The purpose of "ping" is to inform the GUI whether all commands received before have been processed. This can be done by queuing "ping" just like any other command. The remark in the specs just intends to point out that pondering should not be considered processing of any previous command (e.g. "hard"), but is basically just something the engine does as a passtime when it is waiting for the next command.