Page 1 of 1

UCI protocol question - what is bestmove when mated?

PostPosted: 30 Nov 2012, 18:50
by crystalclear
Code: Select all
2012-11-30 17:38:04.158-->1:position startpos moves f2f4 e7e5 f4e5 d7d6 e5d6 f8d6 g2g3 g8f6 e2e3 b8c6 f1b5 d8d7 b5c6 d7c6 g1f3 c8g4 e1g1 g4h3 f1e1 h3g4 e3e4 f6e4 d2d4 e8g8 e1e3 a8e8 e3d3 d6b4 a2a3 b4a5 c2c3 c6g6 b2b4 a5b6 c3c4 g4f5 f3h4 g6g4 c4c5 g4d1 d3d1 f5g4 d1f1 g4h3 h4g2 h3g2 g1g2 e4c5 d4c5 b6c5 b4c5 e8e5 a3a4 e5c5 c1a3 c5c2 f1f2 c2f2 g2f2 f8d8 a4a5 d8d1 g3g4 d1d4 g4g5 d4f4 f2g3 f4a4 a3b2 a4b4 b2c3 b4e4 h2h4 e4e3 g3g4 e3e4 g4h3 e4e6 c3d4 e6a6 b1c3 a6c6 c3d5 c6d6 d5e7 g8h8 d4a7 h7h6 h3g4 d6e6 e7d5 e6e4 g4f5 e4h4 g5h6 h4h6 d5c7 h8g8 f5f4 h6f6 f4e5 g8h8 a1h1 h8g8 h1b1 f6h6 a7c5 h6h5 e5d6 h5h6 d6d7 h6h5 b1b7 h5c5 a5a6 c5c1 a6a7 c1a1 a7a8r a1a8 c7a8 f7f6 d7e6 g8h8 e6f5 h8g8 a8b6 g8h7 b6d5 h7g8 d5f6 g8f8 f6d5 g7g6 f5e6 g6g5 b7b8 f8g7 d5f6 g5g4 b8g8 g7h6 f6g4 h6h7 g8g5 h7h8 e6f7 h8h7 g5h5
2012-11-30 17:38:04.160-->1:go wtime 77000 btime 27000 winc 1000 binc 1000
2012-11-30 17:38:04.191-->1:stop
2012-11-30 17:38:04.192<--1:info string Checkmate!


I am not really happy that Arena sends me a GO command when I am already checkmated. I sort of see that as a problem with Arena, but it is not possible for me to change that, and other programs presumably cope perfectly well. Mine used to crash as I didn't have a "bestmove" available and I still think I have not handled the situation too elegently. I find the whole "end of game" scenarios are poorly covered in chess programming. As I see it (for example) resigning is a move that either player can make at any time during the game. But this question is not about the resignation issue, I just want to know the correct response to a UCI "go" command when already checkmated. I don't want GUIs to hang waiting for a response and I don't really have a move to give them!

Re: UCI protocol question - what is bestmove when mated?

PostPosted: 30 Nov 2012, 19:21
by crystalclear
My next protocol question, and maybe not worthy of its own thread is about AUTODETECT.

Arena again - sorry, I know this is a WINBOARD forum, I do apologise - but I do see it as related ....

There is an autodetect mode. When I configure a new engine I am prompted for protocol, WINBOARD or UCI and I usually reply UCI.
However Arena then sets the protocol to AUTODETECT. I can then later use another menu to manually set it to UCI, but for a while the engine is set to AUTODETECT and my program is often invoked that way because I have forgotten or been to lazy to annul the AUTODETECT mode.

The autodetection seems to work by Arena sending an Xboard command followed by a UCI command to the engine. The idea must be that if the engine has Xboard capabilities it is likely to obey the xboard command and give an Xboard error to the UCI command. If the engine has UCI only capabilities then we can expect a UCI error to the Xboard command. But what if the engine understands both protocols to some extent?

The xboard command is sent first. I guess that means that most engines that support protocols will be put into Xboard mode by the xboard command and then give an error message to the UCI command. Does anyone have an opinions on what is the best way to handle autodetection?

The reason I ask, is that my engine would prefer to be in UCI mode, if given the choice, but there doesn't seem to be any way for the engine to express a preference.
Would it be better if my engine ignored a "uci" command when in Xboard mode, rather than flagged it as an error?

Re: UCI protocol question - what is bestmove when mated?

PostPosted: 30 Nov 2012, 19:54
by H.G.Muller
The UCI specs do not define a response for being set thinking in a mated position; it is tacitly assumed the GUI would not do this. A logical reponse would be to reply with a null move ("bestmove 0000"), combined with a "mated 0" score. This could also be used to let the engine resign. (Resigning when checkmated is usually a good decision, so it is no problem that the two cannot be distinguised.)

Similarly, null-move + 0 score would be the logical response for a draw claim.

As to the autodetect: if your goal is to fool Arena, you can exploit your knowledge of how exactly it autodetects. If what you say is true, letting the engine switch back to UCI mode after it receives "uci" directly after "xboard", like it never saw the "xboard" and just send the UCI options.

But I would not recommend using UCI under Arena if you have a choice. Certainly not if your engine also supports Chess960. (Of course I would not even recommend using Arena under any circumstances... :wink: )

Re: UCI protocol question - what is bestmove when mated?

PostPosted: 30 Nov 2012, 20:51
by crystalclear
Thanks for the replies.