Chess variant question

Discussion of chess software programming and technical issues.

Moderator: Ras

grandmastermac
Posts: 15
Joined: Mon Apr 20, 2020 7:07 am
Full name: Paul Macdonald

Chess variant question

Post by grandmastermac »

Hi there, I am interested in modifying a chess engine to play a chess variant I am working on. The variant only requires 3 pieces to have their move modified and the moves are already well known, Chancellor, Arch-bishop and Wildebeest (also referred to as a Unicorn). All other chess rules stay the same: castling, en passant, stalemate etc. The board dimensions are the same as standard chess.

The requirement is to have humans play bots are various strength levels. Any thoughts on an engine that would suit the purpose, not be subject to licensing contraints and fairly straight forward to interface to via an API or similar. Javascript or WASM would be ideal but open to all ideas.
User avatar
hgm
Posts: 28440
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess variant question

Post by hgm »

Fairy-Max, Sjaak II and Nebiyu will have no problem handling these pieces, and you should be able to have them play your variant by just adding the definition in their respective configuration files. I think all of them already have game definitions for Capablanca and Wildebeest Chess.

KingSlayer is not configurable through an external file, but it should not be very hard to make the slight code modifications (mostly in initialized tables) required to do the pieces you mention. There already exists a version of it that plays Chess with Different Armies, which requires it to handle 22 different piece types, amongst which the Chancellor and Archbishop. (Not all at once, though.) I see that I never really put a license notice in KingSlayer, but as far as I am concerned I could make it public domain.

How many piece types can be on the board at once, in your variant? KingSlayer was originally written to play normal Chess, and its encoding of pieces allowed for only 7 piece types (of which one was unused). I managed to overcome that limit in a version that I adapted for playing Musketeer Chess, but it makes the code a bit ugly.
grandmastermac
Posts: 15
Joined: Mon Apr 20, 2020 7:07 am
Full name: Paul Macdonald

Re: Chess variant question

Post by grandmastermac »

Hi Mr Muller, again thank you for your fantastic insight! You obviously have a lot of experience in this field. To answer your question, our variant only requires 6 piece types maximum on the board at any given time. What would you say would be the strongest of the engines you mentioned?

I had another question. Can you also use configuration files to alter the strength of the engines you mentioned? We are looking to try and get the engine to play at different levels of strength, some at a complete beginner level but some up to 2700 strength.
Last edited by grandmastermac on Thu Apr 23, 2020 2:00 pm, edited 1 time in total.
User avatar
hgm
Posts: 28440
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess variant question

Post by hgm »

"At any given time" might not be good enough for the standard version of KingSlayer, as it expects the meaning of the piece types to stay the same during a single game. In the derivative I made for Chess with Different Armies (which basically is a family of variants) I just added code that at the start of each game reinitializes the move-description tables so that the available pieces become that of the selected armies. Which always contain King, Pawn and 4 other types. The 7th type can then be used for when a player promotes to the opponent's strongest piece. (This is an imperfect implementation, as officially one would also be allowed to promote to weaker opponent pieces, but this would be very rare.)

I guess one could put in code that does this re-initialization of the moves during a game.

In Musketeer Chess 9 different piece types can occur simultaneously, and the way I implemented it also needs two 'combination pieces', representing a stack of two pieces, the lower one remaining when the upper one moves away. To do that in KingSlayer I resorted to a 'non-contiguous' encoding of the pieces, where code 1-7 and 16-23 is used for white pieces, and 9-15 and 24-31 for black pieces. A bit confusing and bug-prone, but it seems to work now.
grandmastermac
Posts: 15
Joined: Mon Apr 20, 2020 7:07 am
Full name: Paul Macdonald

Re: Chess variant question

Post by grandmastermac »

Sorry, that was a confusing statement. The game starts with 6 different types. Just as in FIDE Chess, no other types are introduced during the game. The piece types also don't change and are well defined. 2 Chancellors, 2 Wildebeest, 2 Arch-bishops, 1 Queen, 1 King and 8 pawns.
User avatar
hgm
Posts: 28440
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess variant question

Post by hgm »

OK, I see. A variant designed under the assumption "the stronger the pieces, the better the game". :wink:

I guess that most engines could be converted to play it relatively easily then. I am not really expert on licences of other engines, and it would also depend on what playing strength you are aiming for. I think TSCP allows closed-source derivatives, as long as the author is acknowledged. But it is rather weak. (Still too strong for most humans, though...) You could go up in strength all the way to Ippolit derivatives, such as Robbolito or Ivanhoe (I think these are all public domain).

The stronger the engine, the more specific evaluation is likely to have that will be completely useless in a variant.
grandmastermac
Posts: 15
Joined: Mon Apr 20, 2020 7:07 am
Full name: Paul Macdonald

Re: Chess variant question

Post by grandmastermac »

Harm, do you know if the chess engines you mentioned are portable to web assembly? And how we would interface with it if so? I'm hoping there's a stateless interface so you'll still be able to recover the game from accidental page refresh / disconnection and continue playing the bot.
User avatar
hgm
Posts: 28440
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess variant question

Post by hgm »

I am not that experienced in web programming. You are thinking of something like JavaScript? I know that several people here have developed engines in JavaScript (Lozza, Tomitank Chess), and that there also exists a version of Stockfish ported to JavaScript through some automatic tool.

Standard engine communication protocols do contain commands for setting up arbitrary positions, or loading an arbitrary game history. For UCI you even have to do that before every move you want the engine to make, by sending a position encoded as FEN followed by a sequence of moves ("position fen <FEN> moves <MOVE_1> <MOVE_2> ..."). In CECP ('WinBoard protocol') you don't have to do that, as the engine is in a defined game state after it makes a move from, which you can continue, but you can do it if you want, (by sending "new force setboard <FEN> <MOVE_1> <MOVE_2> ..." separated by linefeeds rather than spaces). It is up to the client to decide how it wants to use the engine.

Perhaps you should repost your question with a title that is more to the point: you are not asking for information about chess variants; you want to know about engines for orthodox Chess that are suitable for web assembly, and have a permissive license. So that you can adapt it to playing your variant. As it is, most programmers would read the title of this thread, and think "I don't know anything about chess variants", and not even open it.
grandmastermac
Posts: 15
Joined: Mon Apr 20, 2020 7:07 am
Full name: Paul Macdonald

Re: Chess variant question

Post by grandmastermac »

Great advice again - thanks Harm. I will repost with a more suitable title and content.
User avatar
hgm
Posts: 28440
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Chess variant question

Post by hgm »

Note that I have been working these past days on committing the derivative of KingSlayer that plays Chess with Different Armies (which I released as a binary a few months ago) to my on-line source repository. (I had developed it under Windows, where I have no version control, so I had a bit of catching up to do.) It is still there under the old name 'simple' (which I later learned was already taken).

I mention this because KingSlayer-CwDA has a limited configurability that could be of use to you: apart from all the different flavors of Chess with Different Armies, it supports a single variant 'custom', which takes the army definitions from a file. These definitions can use all the predefined CwDA pieces (i.e. arbitrarily mix armies), but also allows definition of two custom pieces in terms of the elementary move sets used by the CwDA pieces, plus an arbitrary set of leaper moves the user can define. KingSlayer has this feature because the CwDA implementation was developed for the purpose of investigating how various proposed small rule modifications could better balance the armies. For this it had to be able to also use some non-(CwDA-)standard pieces to experiment with.

The custom leaper move set can easily be defined as Camel moves (a move normally not occurring in CwDA), which can then be used to define a Wildebeest. The Archbishop and Chancellor are already standard pieces in CwDA. So it would be easy to configure this custom variant as yours.