michiguel wrote:bob wrote:Michel wrote:I was simply objecting to the use of the word "hideous" for a command that allows the GUI to ask information from the engine.
There is no need to use such charged words when discussing a communication protocol.
I agree with HGM. Polling is a poor way of doing this. So rather than "hideous" how about "poor approach" or "crappy approach" or "antiquated approach" or "sophmoric approach" or something equally descriptive. Polling is never a good design. It wasn't a good design in MSDos when it polled a disk drive over and over to ask "are you done, yet?". It is not really a good design today when we ask "is there a move to read". We do this because there is no compatible way in windows to avoid this. In unix, it is trivial to use asynchio. One can always eliminate the polling by using a second thread, and then some sort of signaling mechanism to tell the search when you have a new move, etc. And that is a better design as well. In short, polling is a poor solution to a simple problem.
I have a second thread that deals with the "polls". That is still a "poll" from the GUI. I do not know then what you mean by poll because it is not eliminated.
What do you do between polls in the second thread? When I used that approach in Cray Blitz, the second thread just did a normal read() and blocked, while the first thread searched/pondered like mad. When the read() was satisfied, the "read thread" would signal the "search thread" that there was something that required attention.
To poll means to repeatedly ask "do you have a move?" <NO> "do you have a move NOW?" NO. What about NOW? NO. Etc. A read isn't a "poll" it is a blocking operation that causes that thread to stop executing until data is available, rather than sitting in a tight loop asking "is there something to read?"
If you want to see something every N seconds, then we should define a mechanism to make that happen _automatically_.
The user may want to know only once what is going on and do it manually, so being spammed every N seconds just in case the user wants to know something is hideous

That is OK. Again, that is not polling. Polling is something done at regular intervals, such as how xboard sends that "." every so often to get the status information. Sending a "." when a user clicks a box on the GUI is OK, as that is something that would only happen when clocked, not like clockwork, even when nothing has changed...
Crafty has a "burp" parameter that tells it how often to update the current display so that we can tell it is alive in tournament play when ICGA rules do not allow you to hit a key to ask "are you alive".
That is fine, but ICGA tournaments are a small fraction of the universe of CC. I think you agree

No disagreement at all. I just pointed out that sending some sort of status info is something a program can do at the appropriate intervals. For example, the famous "Nh4 21/40" type output. If you want that, the program ought to send it each time it searches a new root move, rather than constantly being asked "got anything new yet?" "got anything new yet?" The program knows when it has something new and interesting to display.
So a solution would be to either (a) let the GUI tell the engine how often to provide some sort of update or (b) let the user tell the engine how frequently he wants to see information (about all that this shows is total nodes and current move being searched, most engines will tell the gui when the score or PV changes or there is a fail-high or fail-low automatically. I think the entire idea could be dropped and just let the engine tell the GUI about current state whenever it feels like it, or not at all.
If the engine is capable to relay information when it is asked, I do not see the problem.
Miguel
We are not quite on the same page. Nothing wrong with the engine being able to respond when asked. But to ask every 2-3 seconds is a waste of time and introduces overhead.