Question about UCI variants

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Kurt22
Posts: 8
Joined: Mon Oct 08, 2018 6:03 pm
Full name: Kurt Kish

Question about UCI variants

Post by Kurt22 » Wed Dec 19, 2018 12:31 am

So I'm making an engine that plays a variant I created - I've modified cutechess so that the rules of the "king of the hill" variant are now the rules of my variant, so all I have to do is add -variant kingofthehill when using cutechess=cli and make my engine (which is an SF fork) support kingofthehill.

How do I do that last part? I'm pretty sure it has something to do with the "UCI_Variant" option, and I guess I'd add it to ucioptions.cpp similarly to the other options SF has like this:

o["UCI_Variant"] << Option( :?: );

but I'm not sure what to put in for the :?: .

Any and all help is appreciated. Thanks!

Toadofsky
Posts: 25
Joined: Sat Dec 03, 2016 1:20 pm
Contact:

Re: Question about UCI variants

Post by Toadofsky » Wed Dec 19, 2018 9:05 am

I suppose: use https://github.com/ddugovic/Stockfish/b ... option.cpp as an example. I'm not a C++17 expert and am unfamiliar with the syntax (in order to explain equivalent ways of writing it) but in this form it works.

Ras
Posts: 1130
Joined: Tue Aug 30, 2016 6:19 pm
Contact:

Re: Question about UCI variants

Post by Ras » Wed Dec 19, 2018 3:32 pm

Yeah, and the variants in the fork above are listed here:
https://github.com/ddugovic/Stockfish/b ... rc/types.h
The enum Variant has to match the static std::vector<std::string> variants I think. E.g. right after the TWOKINGS variant because after that, that's subvariants. And then there are 7 "ifdef TWOKINGS" in the code for blending that in, which shows how to add stuff.

The ucioptions.cpp seems only to set the default value, and the default variant value is just the first variant in the list, so "chess" is the default.
Rasmus Althoff
https://www.ct800.net

User avatar
hgm
Posts: 23297
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Question about UCI variants

Post by hgm » Wed Dec 19, 2018 4:23 pm

Kurt22 wrote:
Wed Dec 19, 2018 12:31 am
I'm pretty sure it has something to do with the "UCI_Variant" option, ...
Note that it is not just a matter of implementing that option, but that the protocol extension also requires the engine to send and info-string-variant command in reply to 'ucinewgame', with the description of the variant, if something different from Chess or Chess960 is selected. E.g.

info string variant kingofthehill startpos rnbqkbnr/pppppppp/8/8/PPPPPPPP/PPPPPPPP/PPPPPPPP/PPPPPPPP kq - 0 1

Kurt22
Posts: 8
Joined: Mon Oct 08, 2018 6:03 pm
Full name: Kurt Kish

Re: Question about UCI variants

Post by Kurt22 » Wed Dec 19, 2018 11:04 pm

Thanks all for the help!

I have been able to get the warning "this engine does not support kingofthehill" to go away, however I still cannot get it to actually play.

Here's what I did:
https://github.com/official-stockfish/S ... v?expand=1
(only the changes in uci.cpp and ucioption.cpp are relevant)

What more do I need to do to get it to actually play? If I load it in a GUI, it plays normal chess with the King of the Hill (well, my variant's) rules, so I assume the issue is that it doesn't know what to do when told to play kingofthehill, and I need to somehow tell it to do what'd it do normally (if this makes any sense).

User avatar
hgm
Posts: 23297
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Question about UCI variants

Post by hgm » Thu Dec 20, 2018 9:20 am

Are you sure Stockfish announces the UCI_Variant option as intended? What does it print when you run it from the command line and type 'uci' ?

Kurt22
Posts: 8
Joined: Mon Oct 08, 2018 6:03 pm
Full name: Kurt Kish

Re: Question about UCI variants

Post by Kurt22 » Thu Dec 20, 2018 10:17 pm

hgm wrote:
Thu Dec 20, 2018 9:20 am
Are you sure Stockfish announces the UCI_Variant option as intended? What does it print when you run it from the command line and type 'uci' ?
Here's what it prints:

uci
id name Stockfish 191218 64
id author T. Romstad, M. Costalba, J. Kiiski, G. Linscott

option name Debug Log File type string default
(more options)
option name UCI_Chess960 type check default false
option name UCI_Variant type combo default Chess var Chess var kingofthehill
option name UCI_AnalyseMode type check default false
(more options)
option name SyzygyProbeLimit type spin default 7 min 0 max 7
uciok

User avatar
hgm
Posts: 23297
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Question about UCI variants

Post by hgm » Fri Dec 21, 2018 7:38 am

Looks OK to me. If an interface would say after this that the engine does not support 'kingofthehill', it should be considered an interface bug.

Kurt22
Posts: 8
Joined: Mon Oct 08, 2018 6:03 pm
Full name: Kurt Kish

Re: Question about UCI variants

Post by Kurt22 » Fri Dec 21, 2018 5:02 pm

hgm wrote:
Fri Dec 21, 2018 7:38 am
Looks OK to me. If an interface would say after this that the engine does not support 'kingofthehill', it should be considered an interface bug.
That part works now - I no longer get warnings about not supporting kingofthehill. The current issue is that my engine simply won’t play it. Instead, it plays with the kingofthehill rules (or my variant’s) only when I tell it to play normal chess (This is intended, but I need it to also play when I tell it to play kingofthehill).

User avatar
hgm
Posts: 23297
Joined: Fri Mar 10, 2006 9:06 am
Location: Amsterdam
Full name: H G Muller
Contact:

Re: Question about UCI variants

Post by hgm » Fri Dec 21, 2018 5:34 pm

That is strange. If you play it always, ignoring the setting of the UCI_Variant option would be all that is needed to make it work.

What was the cause of the initial denial of support for kingofthehill anyway?

Note that Stockfish 10 is not UCI compliant, so if you forked your engine from that, it might contribute to the trouble.

I suppose you are trying this with cutechess-cli, and I am not familiar with how this treats UCI variants. Perhaps it would help if you could make a debug log somehow, and post that here.

Post Reply