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!
Question about UCI variants
Moderators: hgm, Rebel, chrisw
-
- Posts: 10
- Joined: Mon Oct 08, 2018 8:03 pm
- Full name: Kurt Kish
-
- Posts: 27
- Joined: Sat Dec 03, 2016 2:20 pm
Re: Question about UCI variants
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.
-
- Posts: 2488
- Joined: Tue Aug 30, 2016 8:19 pm
- Full name: Rasmus Althoff
Re: Question about UCI variants
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.
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
https://www.ct800.net
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Question about UCI variants
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
-
- Posts: 10
- Joined: Mon Oct 08, 2018 8:03 pm
- Full name: Kurt Kish
Re: Question about UCI variants
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).
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).
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Question about UCI variants
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' ?
-
- Posts: 10
- Joined: Mon Oct 08, 2018 8:03 pm
- Full name: Kurt Kish
Re: Question about UCI variants
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
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Question about UCI variants
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.
-
- Posts: 10
- Joined: Mon Oct 08, 2018 8:03 pm
- Full name: Kurt Kish
Re: Question about UCI variants
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).
-
- Posts: 27808
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Question about UCI variants
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.
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.