Ponder via UCI. I have this functioning but with issues. Cutechess.
Go ponder is easy enough. Set a ponderflag and use it to disallow the search to terminate (eg no bestmove print).
Ponderhit also easy. Just clear the ponderflag and the engine reverts to normal etc
What about opponent does NOT play the pondermove. Is it right to assume here that the GUI then sends stop?
Then what? Obviously engine breaks the search, and bestmove is not senseful, but UCI docs write that go and bestmove are a pair, go must end in bestmove. What happens here? Send a bm? Send nothing? Send a nullmove?
I’ve tried all except nullmove and always get spurious and occasional “warning premature best move”, or illegal bestmove, or sometimes a crash/hang. What do others do?
UCI and ponder
Moderator: Ras
-
- Posts: 4624
- Joined: Tue Apr 03, 2012 4:28 pm
- Location: Midi-Pyrénées
- Full name: Christopher Whittington
-
- Posts: 5695
- Joined: Tue Feb 28, 2012 11:56 pm
Re: UCI and ponder
The engine should just output the bestmove, which the GUI should then ignore.
-
- Posts: 5695
- Joined: Tue Feb 28, 2012 11:56 pm
Re: UCI and ponder
This _might_ have to do with synchronisation issues in the engine. Getting UCI ponder right is not entirely trivial (so I guess UCI failed on this point, because it was supposed to make things easy for the engine). I am fairly sure there is a remaining problem in Cfish, and I know that Stockfish switched to doing an ugly busy loop if the ponder search runs out of things to do to finally overcome some race condition.
If the GUI/cutechess really cannot handle the bestmove, it should crash or report an error every time.
-
- Posts: 1524
- Joined: Wed Apr 21, 2010 4:58 am
- Location: Australia
- Full name: Nguyen Hong Pham
Re: UCI and ponder
The brief logic for UCI engines:
- receive the command "go": start searching, return the best move when time out
- receive the command "ponder": start searching, use the infinite timer, don't return the best move (except receiving "stop"). If the search stops (say, getting a mate), just store the best move but don't send it to the GUI. Typically GUIs don't expect the best moves from pondering engines and may simply ignore them
- receive the command "ponderhit": continue searching but start counting elapsed time (elapsed times are counted from the point of getting that ponderhit), return best moves when time out
- receive command "stop": if searching/pondering, stop it. Always return a/the best move regardless it was searching or not or which commands it received before. If it doesn't have any best move, it may return a null move instead ("0000" but returning any legal move is much better than the null move)
Chess GUIs should take care of all other aspects.
- receive the command "go": start searching, return the best move when time out
- receive the command "ponder": start searching, use the infinite timer, don't return the best move (except receiving "stop"). If the search stops (say, getting a mate), just store the best move but don't send it to the GUI. Typically GUIs don't expect the best moves from pondering engines and may simply ignore them
- receive the command "ponderhit": continue searching but start counting elapsed time (elapsed times are counted from the point of getting that ponderhit), return best moves when time out
- receive command "stop": if searching/pondering, stop it. Always return a/the best move regardless it was searching or not or which commands it received before. If it doesn't have any best move, it may return a null move instead ("0000" but returning any legal move is much better than the null move)
Chess GUIs should take care of all other aspects.
https://banksiagui.com
The most features chess GUI, based on opensource Banksia - the chess tournament manager
The most features chess GUI, based on opensource Banksia - the chess tournament manager
-
- Posts: 28353
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: UCI and ponder
Always print a legal bestmove in the 'bestmove' command, on 'stop' as well as a timeout. Then the GUI should never complain it is illegal.
There is no reason to treat a 'stop' during a ponder search (or an analysis search) differently from a 'stop' during a normal search, or a spontaneous timeout.
There is no reason to treat a 'stop' during a ponder search (or an analysis search) differently from a 'stop' during a normal search, or a spontaneous timeout.
-
- Posts: 4624
- Joined: Tue Apr 03, 2012 4:28 pm
- Location: Midi-Pyrénées
- Full name: Christopher Whittington
Re: UCI and ponder
That makes intuitive sense, but after a “stop”, the position will be in one of two states depending on ponder status. Either before or after the pondermove. Which “legal” bestmove then? What’s legal after ponder is not legal before it. I’ll try sending nullmove in the case of “stop” when pondering.hgm wrote: ↑Thu Dec 08, 2022 9:38 am Always print a legal bestmove in the 'bestmove' command, on 'stop' as well as a timeout. Then the GUI should never complain it is illegal.
There is no reason to treat a 'stop' during a ponder search (or an analysis search) differently from a 'stop' during a normal search, or a spontaneous timeout.
-
- Posts: 28353
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: UCI and ponder
Legal in the position that was set up by the 'position' command preceding the 'go ponder'.
-
- Posts: 4624
- Joined: Tue Apr 03, 2012 4:28 pm
- Location: Midi-Pyrénées
- Full name: Christopher Whittington
Re: UCI and ponder
Done. Seems to function. It’s possible that some problems came from running too many engines concurrently. I can get away with concurrency 60 on my 64x machine, but with ponder, concurrency 60 means that 120 engines are competing for resources at once and either Windows or Cutechess or some time critical thing begins to screw up (drop connection or weird cutechess errors). Concurrency 50 with ponder appears to be ok.