I would like to use an AI engine to test how well the following chess variant would work: The rules are as in usual chess, except

  1. Castling is not possible; instead, the next rule takes its place:
  2. When the king is not in check, it can perform the following move: It can switch places with any piece of its own colour on the 8 neighbouring squares around it. Unlike castling, this move can be performed as many times throughout the game as you want. The following special rules apply:
    • It cannot move itself into check by doing so (surprise!).
    • It cannot move pawns to the player’s first rank (where pawns cannot be in ordinary chess either).
    • If it moves pawns to the player’s eighth rank, that pawn will be promoted as usual.
  3. Any pawn on the player’s second rank can move one or two pieces forward, even if it has previously moved forward and later been moved back by the king. (This is in order to simplify the game so that you don’t have to remember which of your pawns have moved forward previously.)

The rules themselves do not really matter much. What I would like to know is how an AI engine would play against itself with this ruleset. Based on this, I hope to be able to make my own (human) assessment about how “deep” this variant is. I suppose it is possible to modify the rules given to engines like AlphaZero, MuZero, and Leela Chess Zero and ask the engine to teach itself the game as usual. But are there other, easier methods that do not require extensive rewritings of complicated engines?

I am aware of questions like this one and its answer, but it doesn’t seem that the answer can be adapted to support this variant.

  • AI Agents are not particularly clever. "How well would this work?" or "How would you play against yourself with this ruleset?" will baffle them completely, and probably only produce "Quite well" as answer. If you expect any different type of answer (say, "I would win 72.5% with white, 15% with black), you may need to say what your criteria are. It would just possibly also help anyone trying to answer you question,
    – user30536
    Jul 7, 2023 at 14:55
  • 1
    @user30536 No, that wasn’t what I meant by the question. What I meant was that I would like to ask the engine to play the game against itself many times in order to study its playing style and how this affects the game tactically. And then, from looking at these games, I would make my own assessment about how “deep” this variant is, from a human perspective. (I updated the question to clarify this.)
    – Gaussler
    Jul 7, 2023 at 14:59
  • Most engines are optimized to play standard chess. Fairy Stockfish supports some variants. If you want to train the engine with self-learning like Leela Zero for custom rules, you need to implement those rules and see how to setup training yourself.
    – qwr
    Jul 7, 2023 at 15:25
  • What exactly do you mean by " how “deep” this variant is."? What is the name of the variant? Is this variant already played elsewhere? Looks like not difficult to implement. But another issue is the GUI. Or you can just play it manually. In a kp vs k ending, the kp will win even if the defending king is in front of the pawn because the king and pawn can just swap at appropriate moment.
    – ferdy
    Jul 11, 2023 at 8:58

1 Answer 1


Currently there is no “easy” way to do exactly this. The “easiest” way in this case would simply be the right way. You would have to learn a coding language and develop a chess computer using an existing neural network technology.

There are plenty of tutorials online for how to make your own chess computer. You could follow those tutorials, and where it explains how to implement the rules of the game, you would simply implement your own rules in place of the regular chess rules. Once you are finished with creating the game, you would probably want to use NEAT to train an ai to play it. NEAT stands for Neuro Evolution of Augmenting Topologies.

Before putting this massive amount of effort in, I suggest reading the following study: Assessing Game Balance with AlphaZero: Exploring Alternative Rule Sets in Chess.

In this study, they forced the DeepMind project to play variants of chess that didn’t really exist. The most interesting variation was one where pawns could move, but not capture, sideways, in addition to their other moves.

They found that changing the castling rules did not produce much interesting gameplay, though I will note that none of their rules gave the king infinite quasi castling power like you’re describing.

Perhaps the easiest way to do this would be to use our imagination. I am a variants enthusiast and atomic player so I will give it my best shot.

The King is the most important piece in the game and defending it is the most important goal, second only to capturing the opponent’s King. This tells me that the most likely application of your rule change would be to defend the king one move before potential checkmate. There would also be special endgame circumstances where once the majority of pieces were off the board, the king would then carry a pawn on its back to promotion. For example, the king could prevent a pawn from ever being on a dark square against a dark square bishop.

In addition, moves that improve king position and the position of another piece could become strategy. The concept of moving two pieces at once could be seen as overpowered and preferred to the usual methods.

Finally, the last effect from your rule change could be an increase in king walks. There are a handful of grandmaster games where one side for whatever reason has to get up and run, and after 10 or so king moves finally there is room to breathe to deliver a deadly attack. More movement options for the king would make these oddly long king walks more possible to accomplish.

In terms of depth, it would be technically deeper than chess since it offers more move possibility. Which giant number to compare to shannons number I wouldn’t know how to calculate.

If that doesn’t sound interesting to you, how about a variant where any piece can do a neighborly swap? Now that would create a game that looks alien to players.

All in all the answer to this question is yours to decide, but hopefully this gives you some insight as to what goes into this sort of thing.

Edit: OP pointed out that this rule change now allows bishops to swap colors. This opens up possibilities for bishops to defend eachother. As early as move 1 you could elect to have two same color bishops.

  • 1
    Let me add what I think would be one of the most crucial applications of this rule: The ability to make a light-squared bishop into a dark-squared one or vice versa.
    – Gaussler
    Jul 7, 2023 at 17:33
  • Completely missed this. I think this would be an entertaining variant, and one that would be difficult to master.
    – Matthew
    Jul 7, 2023 at 18:22
  • 2
    Currently there is no “easy” way to do exactly this. The “easiest” way in this case would simply be the right way. You would have to learn a coding language and develop a chess computer using an existing neural network technology. Is this correct? I have never done that, but I imagine modifying Lczero's source code to change the core rules is much less work than starting development from zero. And you don't mention training time, which rates to be the most expensive part (in terms of time, computing resources, or both). Jul 9, 2023 at 9:04
  • @FedericoPoloni I thought about doing exactly that, but I have no idea how many computer resources it would require to reach an advanced level. How far could you get by letting it run in a cheap work laptop?
    – Gaussler
    Jul 13, 2023 at 13:59
  • 2
    @Gaussler I have no idea either; I have no experience in that area unfortunately. Hopefully the training time could be reduced by starting from a network pre-trained for regular chess, since the two games are similar in the end. And I wouldn't use a cheap laptop but rather buy cloud computing resources. From what i can read on the internet about lczero's training, I would guess between 100-1000$ to get to superhuman level, but my estimate could be far off since I know very little about it. Jul 13, 2023 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.