Hint command in analysis mode

Discussions about the WinBoard protocol. Here you can also report bugs and request new features.

Moderators: hgm, Andres Valverde

Hint command in analysis mode

Postby Tony Mokonen » 26 Aug 2019, 19:55

I am in the process of adding a properly working analyze mode to my engine. The last release of my engine only supported the exit command while in analyze mode, and I wanted to add full support for all the commands laid out in the CECP protocol (https://www.gnu.org/software/xboard/engine-intf.html#12).

I was having an issue with the hint command, however. The hint command works fine when not in analyze mode. When I select Hint... from the menu in Analyze mode, Winboard displays a popup stating "No hint available", even though my engine is capable of displaying a hint while analyzing. I tried the -debug option in the startup dialog to generate a winboard.debug log file, and no hint command is sent by the GUI when Hint... is selected from the menu, and the GUI is in analyze mode. I was using Winboard 4.9.1, but the same thing occurs with older versions of Winboard. I also tried with a different engine (Tucano 7.07) to confirm that it's the GUI, and not my engine. I know it's the most minor of issues, since hints are rather redundant when you have the full analysis right there, but technically it is part of the protocol.

This is a sample winboard.debug file. I tried a hint after the PV at depth 9 was printed. For now, I am not doing anything with the "." command. I am also curious as to what Impossible move , type = 0 means in the log file.

Code: Select all
recognized 'normal' (-1) as variant normal
recognized 'normal' (-1) as variant normal
shuffleOpenings = 0
Version: WinBoard 4.9.1 + Tony's
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
shuffleOpenings = 0
StartChildProcess (dir=".") Tony's Chess
688 >first : xboard
protover 2
703 <first : Tony's Chess
703 <first : Version 0.04 r3
703 <first : 2019 Tony Mokonen
703 <first : Type help to display help
703 <first : feature done=0
703 >first : accepted done
703 <first : Moves left set to 30
703 <first : Overhead left set to 10
703 <first : Resign score value set to -1000
703 <first : Hash size set to 256 MB
703 <first : Invalid file name tonys.fbk
703 <first : feature ping=0
703 >first : accepted ping
703 <first : feature setboard=1
703 >first : accepted setboard
703 <first : feature playother=0
703 >first : accepted playother
703 <first : feature san=0
703 >first : accepted san
703 <first : feature usermove=0
703 >first : accepted usermove
703 <first : feature time=1
719 >first : accepted time
719 <first : feature draw=0
719 >first : accepted draw
719 <first : feature sigint=0
719 >first : accepted sigint
719 <first : feature sigterm=0
719 >first : accepted sigterm
719 <first : feature reuse=1
719 >first : accepted reuse
719 <first : feature analyze=1
719 >first : accepted analyze
719 <first : feature myname="TonysChess 0.04 beta r3"
719 >first : accepted myname
719 <first : feature variants="normal"
719 >first : accepted variants
719 <first : feature colors=0
719 >first : accepted colors
719 <first : feature ics=0
719 >first : accepted ics
719 <first : feature name=1
719 >first : accepted name
719 <first : feature pause=0
719 >first : accepted pause
719 <first : feature debug=0
719 >first : accepted debug
719 <first : feature memory=0
719 >first : accepted memory
719 <first : feature smp=0
719 >first : accepted smp
719 <first : feature egt=0
719 >first : rejected egt
719 <first : feature exclude=0
719 >first : accepted exclude
719 <first : feature setscore=0
719 >first : rejected setscore
719 <first : feature highlight=0
719 >first : accepted highlight
719 <first : feature option="Hash -spin 256 1 1024"
719 >first : accepted option
719 <first : feature option="Clear Hash -button"
719 >first : accepted option
719 <first : feature option="Moves Left -spin 30 1 100"
719 >first : accepted option
719 <first : feature option="Overhead -spin 10 0 10000"
719 >first : accepted option
719 <first : feature option="Resign Moves -spin 3 0 10"
719 >first : accepted option
719 <first : feature option="Resign Score -spin -1000 -5000 -1"
719 >first : accepted option
719 <first : feature done=1
719 >first : accepted done
766 >first : new
766 >first : level 40 5 0
766 >first : post
766 >first : hard
Impossible move , type = 0
4156 >first : force
4156 >first : analyze
Impossible move , type = 0
4156 <first : 1 9 0 1 a2a3
4156 <first : 1 16 0 5 c2c3
4156 <first : 1 35 0 8 d2d4
4156 <first : 1 36 0 19 g1f3
4172 <first : 2 0 0 41 g1f3 g8f6
4172 <first : 3 35 0 131 g1f3 g8f6 d2d4
4172 <first : 4 0 0 238 g1f3 g8f6 d2d4 d7d5
4172 <first : 5 33 0 1577 g1f3 g8f6 d2d4 d7d5 b1c3
4172 <first : 6 0 1 13999 g1f3 g8f6 d2d4 d7d5 b1c3 b8c6
4250 <first : 7 28 9 98443 g1f3 g8f6 d2d4 d7d5 b1c3 b8c6 c1e3
4531 <first : 8 0 38 442050 g1f3 d7d5 b1c3 g8f6
5141 <first : 8 9 99 1094911 e2e4 b8c6 d2d4 d7d5 e4d5 d8d5 g1f3 g8f6
6156 >first : .
6844 <first : 9 35 268 3128869 e2e4 e7e6 b1c3 d7d5 g1f3 d5d4 c3b5 g8f6 f1d3
12062 <first : 10 7 791 9472474 e2e4 e7e5 g1f3 g8f6 b1c3 f8d6 f1d3 b8c6 c3b5 d6c5
GameEnds(29, xboard exit, 2)
14202 >first : exit
14202 >first : quit
User avatar
Tony Mokonen
Posts: 77
Joined: 25 Jul 2005, 19:30
Location: Vancouver, BC, Canada

Re: Hint command in analysis mode

Postby H.G.Muller » 26 Aug 2019, 22:32

I looked at the code, and it seems this is intended behavior. The 'HintEvent' routine only makes an attempt to get a hint move from the engine when the engine is playing against a human, and then only when the human is on move. In other cases it either says "Wait until your turn" or "No hint available".

I don't see how it could be very useful to ask for a hint in analyze mode; the whole idea of analyze mode is that the engine continuously spits out hints, which you can then read in the Engine Output window. If anything is wrong here, it would be that the Hint menu item is not greyed out, I think.

It is true that the CECP specs state that the engine should be able to receive 'new', 'setboard' and 'hint' commands during analysis, but in practice WinBoard would never send such commands during analysis. The 'new game' menu item always switches the engine back to Machine Black, the Edit Position menu (or Paste Position) always switch it to Edit Game mode. A GUI is of course not required to use every feature of the protocol that exists. But I have no idea why these commands in analyze mode were added to the v2 protocol if WinBoard does not use them. The commands also seem superfluous: if it was really desirable that the GUI would stay in analyze mode after, say, pasting a FEN, it could have been achieved by letting WinBoard send 'exit' + 'setboard' + 'analyze' in that case; I cannot think of any ill effects this would have.

The 'impossible move' stuf is debug output from the move parser, which apparently is called at that point to test if something was a move that turns out not to be one. I don't exactly know what it is trying to parse at this point. I gusee the whole printf could be deleted, as we know the move parser to work correctly by now.
User avatar
Posts: 3380
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Re: Hint command in analysis mode

Postby Tony Mokonen » 27 Aug 2019, 03:05

Thanks for the response, Harm. I won't bother with hints in analyze mode.

Different GUIs have different quirks. Arena always sends an exit first no matter what you try to do in analyze mode (an undo command sequence would be exit/undo/analyze), and I got caught with my pants down assuming that every GUI did this, rather than reading the protocol closely enough. I want to be compatible with the popular GUIs (Winboard, Arena, Chessmaster, Scid), so in the name of compatibility (and self torture :?), I will have to test with all of them to see if they do something goofy that Winboard doesn't do, like sending new commands in analyze mode.
User avatar
Tony Mokonen
Posts: 77
Joined: 25 Jul 2005, 19:30
Location: Vancouver, BC, Canada

Re: Hint command in analysis mode

Postby H.G.Muller » 28 Aug 2019, 08:19

True, no matter how silly some commands are, once the protocol allows them, you can never be sure that no GUI will ever use them. This whole set of analyze-mode commands in CECP seems ill thought. It seems to have been added just like one engine (Crafty?) happened to support it. For instance, in all my engines the treatment of 'exit' is 100% identical to the treatment of 'force', which makes one wonder why these are separate commands. And in the engine it would always be necessary to abort an ongoing search, and start a new one, after a change of the root position. So why put the burden on an engine to conclude this, rather than having the GUI order it through explicit 'exit' and 'analyze' commands? That the GUI has to poll for the 'periodic updates' info, rather than having the engine provide it spontaneously when it changes is also pretty silly.

The way I usually implement analyze mode is that '.' is either ignored or causes printing of a stat0 command from some infos most-recently saved in the root, and any other input aborts the search and just returns to the main command-processing loop to handle it. (So this loop only reads a new command if the input buffer was not already containing one.) If the engine is (still) in analyze mode after handling the command, it then starts a new search. This effectively allows any command during analysis. The only caveat is then the 'new' command; normally this would always switch the engine to 'play black' mode, but this should be suppressed when in analyze mode.

The only case I can imagine where it would make sense to continue an ongoing analysis search on reception of a command would be after an 'exclude' command that excludes a move currently not being searched and not the best; it could then simply de skipped once it comes up again in the root. But this seems to occur so rarely that it isn't really worth making an exception for it.

When you do speculative pondering there are a few other commands that should not abort a (ponder) search, in particular 'time', 'otim' and 'usermove' (if the latter is a ponder hit), so in addition to '.' these need to be processed during search as well. That also holds for 'pause'/'resume', if the engine supports that. I usually also handle 'post' and 'nopost' during search (although I am not sure why anyone would want to use those commands at all),
User avatar
Posts: 3380
Joined: 16 Nov 2005, 12:02
Location: Diemen, NL

Return to WinBoard development and bugfixing

Who is online

Users browsing this forum: No registered users and 2 guests