Hey, I have a question for all you gurus.
I am confused about what I am supposed to do on a ponder miss. When I use Arena, it sends a stop, then waits for me to send a move, then sends the new position for me to look at. Fine, easy enough. But when I use polyglot, it sends a stop, then immediately sends the new position...so if I send a move and it arrives after the new position was sent, things get confused because the receiver thinks the move is for the new position instead of being left over from the ponder (and thus should be discarded). The question is, how do I stay compatible with both?
I have been using some SyncStop option to make polyglot act more like Arena, but the instructions for SyncStop basically says only idiots have to use this option, and it may later be discontinued. Fair enough, but it makes me wonder how all you non-idiots address this issue?
-Sam
UCI ponder confusion
Moderator: Ras
-
- Posts: 183
- Joined: Tue Jun 20, 2006 4:41 am
- Location: USA
Re: UCI ponder confusion
After receiving "stop", my engine would block any further input from coming in until it prints out its "bestmove". I have an input thread, which would wait until the bestmove was sent, before calling fgets again (should be within a few milliseconds at most). It's probably a good idea to avoid blocking input in general, but if it's for a very short period of time, I think it's fine, and it can be useful to avoid race conditions.
I added UCI support to my engine fairly recently, and I don't know of any problems with my implementation so far, but it might not be very well tested yet.
I added UCI support to my engine fairly recently, and I don't know of any problems with my implementation so far, but it might not be very well tested yet.
-
- Posts: 183
- Joined: Tue Jun 20, 2006 4:41 am
- Location: USA
Re: UCI ponder confusion
By the way, this issue reminded me of another UCI-related issue that I made a similar suggestion about, on the WBEC-Ridderkerk forum:
http://wbec-ridderkerk.forumotion.com/w ... se-t82.htm
http://wbec-ridderkerk.forumotion.com/w ... se-t82.htm
Re: UCI ponder confusion
Can you post the log ?BubbaTough wrote:Hey, I have a question for all you gurus.
I am confused about what I am supposed to do on a ponder miss. When I use Arena, it sends a stop, then waits for me to send a move, then sends the new position for me to look at. Fine, easy enough. But when I use polyglot, it sends a stop, then immediately sends the new position...
I don't understand how you could send a move on a ponder miss under Arena if the ui don't ask you to search. You are not supposed to do anything on a ponder miss, you can not even send a best move because your move is perhaps illegal in the new position.
HJ.
-
- Posts: 1154
- Joined: Fri Jun 23, 2006 5:18 am
Re: UCI ponder confusion
I am on travel and not near a computer I could get you a log on...I can do post one in a few days time if you are still interested. If memory serves, on a ponder miss the first thing Arena does is send a "STOP" command; if you don't send a move after this, Arena will just sit and wait until you do before sending you the new position. It just throws the move you do send away of course, because as you say, the move may well be illegal. After it throws your move away then it sends you the new position.I don't understand how you could send a move on a ponder miss under Arena if the ui don't ask you to search.
-Sam
Re: UCI ponder confusion
Avoid Polyglot by implementing the winboard protocolBubbaTough wrote: I have been using some SyncStop option to make polyglot act more like Arena, but the instructions for SyncStop basically says only idiots have to use this option, and it may later be discontinued. Fair enough, but it makes me wonder how all you non-idiots address this issue?

It seems to me that Arena is implementing it correctly. From the UCI specs:
Code: Select all
* stop
stop calculating as soon as possible,
don't forget the "bestmove" and possibly the "ponder" token when finishing the search
Richard.
-
- Posts: 1154
- Joined: Fri Jun 23, 2006 5:18 am
Re: UCI ponder confusion
Hmmm....it sounds like Richard is saying that I am already doing things perfectly...and all my problems are really polyglots fault! Well, that makes a lot of sense to me!It seems to me that Arena is implementing it correctly. From the UCI specs:I interpret this as 'any' search. So you always have to send bestmove, even when it does not have a real meaning.Code:
* stop
stop calculating as soon as possible,
don't forget the "bestmove" and possibly the "ponder" token when finishing the search
Richard.
-Sam (busily trying to ignore all suggestions made by Richard implying I need to do more work)
Re: UCI ponder confusion
mh ok you were right i'm also sending a move anytime i receive a stop.
but i've never used polyglot since i'm also supporting winboard.
Looking at polyglot source i have the feeling that it should work ok, ie the first 'bestmove' sent after the stop is allways discarded on a ponder miss.
my_log("POLYGLOT PONDER -> THINK (miss)\n");
uci_send_stop(Uci);
State->state = THINK;
State->exp_move = MoveNone;
void uci_send_stop(uci_t * uci) {
ASSERT(uci_is_ok(uci));
ASSERT(uci->searching);
ASSERT(uci->pending_nb>=1);
engine_send(Engine,"stop");
uci->searching = false;
}
....
} else if (my_string_equal(command,"bestmove")) {
// search end
ASSERT(uci->pending_nb>0);
if (uci->searching && uci->pending_nb == 1) {
// current search
uci->searching = false;
uci->pending_nb--;
event = parse_bestmove(uci,argument); // updates uci->best_move and uci->ponder_move
} else {
// obsolete search
if (uci->pending_nb > 0) {
uci->pending_nb--;
if (uci->pending_nb == 0) event = EVENT_STOP; }
}
but i've never used polyglot since i'm also supporting winboard.
Looking at polyglot source i have the feeling that it should work ok, ie the first 'bestmove' sent after the stop is allways discarded on a ponder miss.
my_log("POLYGLOT PONDER -> THINK (miss)\n");
uci_send_stop(Uci);
State->state = THINK;
State->exp_move = MoveNone;
void uci_send_stop(uci_t * uci) {
ASSERT(uci_is_ok(uci));
ASSERT(uci->searching);
ASSERT(uci->pending_nb>=1);
engine_send(Engine,"stop");
uci->searching = false;
}
....
} else if (my_string_equal(command,"bestmove")) {
// search end
ASSERT(uci->pending_nb>0);
if (uci->searching && uci->pending_nb == 1) {
// current search
uci->searching = false;
uci->pending_nb--;
event = parse_bestmove(uci,argument); // updates uci->best_move and uci->ponder_move
} else {
// obsolete search
if (uci->pending_nb > 0) {
uci->pending_nb--;
if (uci->pending_nb == 0) event = EVENT_STOP; }
}
-
- Posts: 4052
- Joined: Thu May 15, 2008 9:57 pm
- Location: Berlin, Germany
- Full name: Sven Schüle
Re: UCI ponder confusion
From what I can read, currently it seems you will need the SyncStop option. But you are right, it is described as a workaround that is not guaranteed to exist in future PolyGlot versions. From http://wbec-ridderkerk.nl/html/details1/PolyGlot.html:BubbaTough wrote:Hmmm....it sounds like Richard is saying that I am already doing things perfectly...and all my problems are really polyglots fault! Well, that makes a lot of sense to me!It seems to me that Arena is implementing it correctly. From the UCI specs:I interpret this as 'any' search. So you always have to send bestmove, even when it does not have a real meaning.Code:
* stop
stop calculating as soon as possible,
don't forget the "bestmove" and possibly the "ponder" token when finishing the search
Richard.
-Sam (busily trying to ignore all suggestions made by Richard implying I need to do more work)
I expect that there must have been an important reason for Fabien to design PolyGlot this way. UCI and WB are handling ponder misses differently:Work arounds are identical to options except that they should be used
only when necessary. Their purpose is to try to hide problems with
various software (not just engines). The default value is always
correct for bug-free software.
IMPORTANT: Any of these work arounds might be removed in future
versions of PolyGlot. You are strongly recommended to contact the
author of faulty software and truly fix the problem.
PolyGlot 1.4 supports the following work arounds:
[...]
- "SyncStop" (*** NEW ***, default: false)
When a ponder miss occurs, Polyglot interrupts the engine and
IMMEDIATELY launches a new search. While there should be no problem
with this, some engines seem confused and corrupt their search board.
"SyncStop" forces PolyGlot to wait for the (now useless) ponder search
to finish before launching the new search.
- UCI is aware of the move being pondered, and therefore knows whether the opponent's move is a hit or a miss. So UCI reacts differently in these two cases. In case of a hit, UCI sends "ponderhit", and the engine can continue its search. On a miss, it sends "stop" to the engine and will initiate a new search itself.
- WB is not aware of the move being pondered. It simply sends the opponent's move to the engine, and can't know for sure whether it's a hit or a miss. The engine either continues its search (on a hit) or starts a new one. In either case the engine will at some point respond with its move.
So when receiving a move from WB and knowing that this is a ponder miss for the UCI engine, PolyGlot has to change its state such that it will ignore the next "bestmove" reply from the UCI engine, since WB does not expect a reply from the engine that reports the (useless) best move from the aborted ponder search. In fact that seems to be exactly how PolyGlot behaves when SyncStop is set, when looking into the source, so the only question is why this is not the standard behaviour.
Again, there must be a good reason for it.
Maybe this topic has already been discussed here in the past, I did not search.
Sven
-
- Posts: 1154
- Joined: Fri Jun 23, 2006 5:18 am
Re: UCI ponder confusion
It looks like from your code snippet polyglot is trying to address the issue. Nevertheless, if memory serves my debugging indicated that if the sequence was:Looking at polyglot source i have the feeling that it should work ok, ie the first 'bestmove' sent after the stop is allways discarded on a ponder miss.
poylgot -> "STOP"
polyglot -> "NEWPOSITIONTOSEARCH"
myprogram -> "OLDPONDERMOVE"
Things went bad. Most of the times things worked though, because a much more common sequence is:
poylgot -> "STOP"
myprogram -> "OLDPONDERMOVE"
polyglot -> "NEWPOSITIONTOSEARCH"
which works fine. Of course, the problem could always be on my end. It would be nice to know if polyglot works in the first sequence for others.
-Sam