## Chess engines for circular chess boards

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Daniel Shawul
Posts: 4073
Joined: Tue Mar 14, 2006 10:34 am
Location: Ethiopia
Contact:

### Re: Chess engines for circular chess boards

Evert wrote:
Mon Apr 22, 2019 9:51 pm
Wow, that is a board with some seriously odd topology.
That is a "cubed sphere grid" without the bottom plane. It may even be more fun to have the bottom plane with the 6-faces laid out on a plane like -|--,
without boundaries. Corners could be problematic. It will be hard to visualize it as a sphere though unless you have a 3D globe as a playing board.

I think adding a 'periodic' boundary to your piece moving logic can handle this and similar games.

Daniel

RichV
Posts: 53
Joined: Sun Apr 14, 2019 3:33 pm
Full name: Rich VanDeventer

### Re: Chess engines for circular chess boards

An "L" shaped move for a Knight is how the local Chess Academies teach it. They say the Knight moves 1 square across a side then changes direction and moves straight 2 squares across sides, or it can first move straight across 2 squares across sides then change direction and move 1 square across sides. Thus the Knight moves over a total of 3 squares (landing on the third square). I have heard a few chess players talk about moving diagonally one square, then orthogonally one square, moving a total of 2 squares. It is probably a US vs Europe thing.

Wikipedia, on page https://en.wikipedia.org/wiki/Knight_(chess), explains the Knight's move as:

"The knight move is unusual among chess pieces. It moves to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. The complete move therefore looks like the letter "L". Unlike all other standard chess pieces, the knight can "jump over" all other pieces (of either color) to its destination square.[2] It captures an enemy piece by replacing it on its square. The knight's ability to "jump over" other pieces means it tends to be at its most powerful in closed positions, in contrast to a bishop. The knight moves alternately to light and dark squares."

In the number [2] footnote, Wikipedia goes on to say "Because of this, the move can also be described other ways, such as one square diagonally and one square orthogonally "outward" (not ending adjacent to its starting square), or one square orthogonally followed by one square diagonally outward. The latter describes the move of the horse in xiangqi, which cannot jump."

I think the local chess coaches seem to believe that the "L" move is easier for a first grader to understand than using the term diagonally followed by orthogonally in an outward direction. On a square (or rectangular) board, the Knights get to the same squares no matter which move description is used. However, on a circular board that has been merged with a square board which results in 4 triangular spaces, only the "L" shaped moves work everywhere on the board in the same manner and is easier to explain to a new player for Castle Siege Chess.

Thank you for responding, because now I know where the alternate Knight move description (diagonally then orthogonally moving outward) comes from. For Castle Siege Chess, I will keep it simple and stick with the "L" shaped moves across sides.

RichV
Posts: 53
Joined: Sun Apr 14, 2019 3:33 pm
Full name: Rich VanDeventer

### Re: Chess engines for circular chess boards

Daniel, I don't understand how you see my CirSquare 96 chess board as being a sphere. It is a 2D, single-plane circular board with a square board merged into its center. Trying to inflate the board into a spherical shape would double the number of squares from 96 to 192 with two identical halves of the sphere that look like the 2d shape. That might be really cool for playing Castle Siege Chess Bughouse.

Of course, not being a professional electronic game programmer, I probably completely misunderstood your cubic spherical comment. If I did, could please elaborate so that I can understand how my board could be coded as a cubic spherical shape. Thanks.

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

### Re: Chess engines for circular chess boards

Without the bottom plane proposed by Daniel it is of course not topologically equivalent to a sphere. But it is part of a cube with 'rounded' corners and edges (like with good dice), the triangles being the corners, the faces being 4x4 and the edges being 4x1 strips between them.

When I was taught to play Chess I was indeed taught that Knights moved one step orthogonally followed by one step diagonally outward. Although later I have seen the L-shaped orthogonal description often enough. Being a leaper the path of course doesn't matter. I guess we are also influenced by Xiangqi, where the Horse is a lame Knight, so that the path is unambiguously anchored in the rules. There the squares where it can be blocked are only the orthogonal ones, corresponding with the orthogonal + diagonal description.

Evert
Posts: 2929
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

### Re: Chess engines for circular chess boards

RichV wrote:
Wed Apr 24, 2019 11:19 pm
An "L" shaped move for a Knight is how the local Chess Academies teach it. They say the Knight moves 1 square across a side then changes direction and moves straight 2 squares across sides, or it can first move straight across 2 squares across sides then change direction and move 1 square across sides. Thus the Knight moves over a total of 3 squares (landing on the third square). I have heard a few chess players talk about moving diagonally one square, then orthogonally one square, moving a total of 2 squares. It is probably a US vs Europe thing.

Wikipedia, on page https://en.wikipedia.org/wiki/Knight_(chess), explains the Knight's move as:

"The knight move is unusual among chess pieces. It moves to a square that is two squares away horizontally and one square vertically, or two squares vertically and one square horizontally. The complete move therefore looks like the letter "L". Unlike all other standard chess pieces, the knight can "jump over" all other pieces (of either color) to its destination square.[2] It captures an enemy piece by replacing it on its square. The knight's ability to "jump over" other pieces means it tends to be at its most powerful in closed positions, in contrast to a bishop. The knight moves alternately to light and dark squares."

In the number [2] footnote, Wikipedia goes on to say "Because of this, the move can also be described other ways, such as one square diagonally and one square orthogonally "outward" (not ending adjacent to its starting square), or one square orthogonally followed by one square diagonally outward. The latter describes the move of the horse in xiangqi, which cannot jump."

I think the local chess coaches seem to believe that the "L" move is easier for a first grader to understand than using the term diagonally followed by orthogonally in an outward direction. On a square (or rectangular) board, the Knights get to the same squares no matter which move description is used. However, on a circular board that has been merged with a square board which results in 4 triangular spaces, only the "L" shaped moves work everywhere on the board in the same manner and is easier to explain to a new player for Castle Siege Chess.

Thank you for responding, because now I know where the alternate Knight move description (diagonally then orthogonally moving outward) comes from. For Castle Siege Chess, I will keep it simple and stick with the "L" shaped moves across sides.
Your game, so your rules. Personally, I find “2 orthogonal + 1 perpendicular” leads to the least intuitive move on this board, because the shape of the move gets distorted so much.

The FIDE rules define the Knight move as “to the closest space that is not on the same rank, file, or (anti)diagonal as the Knight.” That leads to the same moveset as W+F.

I don’t remember how I was first tought the Knight move. I know I visualised it as per the FIDE description, but I certainly didn’t learn that first. My first association with W+F probably does come from Xiangqi, though.

Evert
Posts: 2929
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

### Re: Chess engines for circular chess boards

Daniel Shawul wrote:
Wed Apr 24, 2019 10:59 pm
Evert wrote:
Mon Apr 22, 2019 9:51 pm
Wow, that is a board with some seriously odd topology.
That is a "cubed sphere grid" without the bottom plane. It may even be more fun to have the bottom plane with the 6-faces laid out on a plane like -|--,
without boundaries. Corners could be problematic. It will be hard to visualize it as a sphere though unless you have a 3D globe as a playing board.

I think adding a 'periodic' boundary to your piece moving logic can handle this and similar games.
It’s not quite so simple, I think. At least the simple periodic boundaries end up with a torus.
In terms of a regular board you’d need to equivalence “a9”=“e8” but that violates parity. You ptobably need to equivalence a8=e8 and so on.
Neat though. I do think the triangles are a problem for any simple coordinate system, but maybe I’ve been approaching it incorrectly. I’ve been thinking in terms of modified spherical or polar coordinates.

RichV
Posts: 53
Joined: Sun Apr 14, 2019 3:33 pm
Full name: Rich VanDeventer

### Re: Chess engines for circular chess boards

Thanks Harm, Daniel, and Evert,

You guys are way over my head in programming land. I envy your command of electronic game programming. I wish that I was even half as knowledgeable/intelligent as any of you.

From the discussion, so far it seems that my game is facing two dilemmas (or difficulties/problems):
1. Choosing between 3 known move descriptions for the Knights:
• Wikipedia’s “L” description
• Evert’s Wazir move – one space orthogonally then one space diagonally
• Harm’s Xiangqi move – one space diagonally and then one space orthogonally
2. Choosing between a 2D or 3D chess engine programming language/tool:
• 2D – staying with Zillions of Games and suffering with the \$25 per user cost; or finding another 2D chess engine that works as well as Zillions and is free for the chess players
• 3D – attempting to see if Jocly, or a similar program, can manage to be programmed without difficulty/errors for alternate path moves through the four triangles on CirSquare 96 (the Castle Siege Chess board)
If I must decide on one Knight move and stick with it, I will go with the Wikipedia “L” shaped move. However, if it would be easy to provide the players with a choice at the beginning of a game to choose which way (their favorite way) they want the Knight to move by making a selection on the screen, that might even be better. That would mean only changing the code for 4 Knight moves in both the Wazir and Xiangqi methods. But that would mean more coding and clear, simple descriptions of each choice for how it affects a Knight’s movement through the triangles:
1. “L” move increases the power of the Knight slightly by covering 9 spaces instead of 8
2. Waxir move decreases the power of the Knight slightly by covering only 7 spaces instead of 8
3. Xiangqi move decreases the power of the Knight slightly by covering only 7 spaces instead of 8

I would still prefer to play the “L” move because increasing the power of the Knight slightly when moving through a triangle is consistent with the increase in power for the Queen, Rook, and Bishop when they move through the triangles. It is also consistent with the overall concept of the Castle Siege Chess board being more powerful than a rectangular board, not only because of the three directions of attack instead of just one, but also because of the dynamic moves through the triangles.

As for having to select between staying with a 2D chess engine or attempting to develop in a 3D chess engine, I am afraid that is going to have to be solved by someone with much more programming knowledge than me. I hope that someday soon I can find such a person(s).

Evert
Posts: 2929
Joined: Fri Jan 21, 2011 11:42 pm
Location: NL
Contact:

### Re: Chess engines for circular chess boards

RichV wrote:
Thu Apr 25, 2019 2:47 pm
From the discussion, so far it seems that my game is facing two dilemmas (or difficulties/problems):
1. Choosing between 3 known move descriptions for the Knights:
• Wikipedia’s “L” description
• Evert’s Wazir move – one space orthogonally then one space diagonally
• Harm’s Xiangqi move – one space diagonally and then one space orthogonally
2. Choosing between a 2D or 3D chess engine programming language/tool:
• 2D – staying with Zillions of Games and suffering with the \$25 per user cost; or finding another 2D chess engine that works as well as Zillions and is free for the chess players
• 3D – attempting to see if Jocly, or a similar program, can manage to be programmed without difficulty/errors for alternate path moves through the four triangles on CirSquare 96 (the Castle Siege Chess board)
To be clear: HGM’s Horse move is the same as the move I mentioned. A “Wazir” is a piece that moves one step orthogonally, a “Ferz” is a piece that moves one step diagonally. These are elementary moves that form the basis for describing the moves of other pieces.
A King moves as a Wazir or a Ferz (WF).
A Rook moves continuously as a Wazir (W-rider).
A Horse moves first as a Wazir, then as a Ferz in the same direction (W-F).

Normally, the knight doesn’t move “first as such and then so” because it leaps and doesn’t care about intermediate squares. There happen to be several common ways to describe a knight move. For your game, you need to specify what happens near the triangular squares and then suddenly it matters.

As to writing a program to play the game: this shouldn’t be too hard as such, it’s a matter of figuring out the best datastructure to use. How pieces move depends on where they are on the board (because of the triangular squares) and that complicates things. What is hard is writing a GUI for the player to interact with.
If I must decide on one Knight move and stick with it, I will go with the Wikipedia “L” shaped move. However, if it would be easy to provide the players with a choice at the beginning of a game to choose which way (their favorite way) they want the Knight to move by making a selection on the screen, that might even be better. That would mean only changing the code for 4 Knight moves in both the Wazir and Xiangqi methods. But that would mean more coding and clear, simple descriptions of each choice for how it affects a Knight’s movement through the triangles:
1. “L” move increases the power of the Knight slightly by covering 9 spaces instead of 8
2. Waxir move decreases the power of the Knight slightly by covering only 7 spaces instead of 8
3. Xiangqi move decreases the power of the Knight slightly by covering only 7 spaces instead of 8
Don’t ask the player to pick between rule alternatives. It just leads to more confusion. I suggest not giving players a choice on the availability of en-passant moves or not. They’re either part of the game, or not.

On the topic of moves though: your website mentions castling, noting that it works as normal, but it isn’t obvious how that would work because the King and Rook are not aligned.

RichV
Posts: 53
Joined: Sun Apr 14, 2019 3:33 pm
Full name: Rich VanDeventer

### Re: Chess engines for circular chess boards

Thanks for correcting me on the name of the piece that moves one space diagonally and then one space orthogonally. In its footnote, Wikipedia gave two examples of alternate move descriptions for the Knight, the first being diagonally then orthogonally and the second being orthogonally then diagonally. It only named the latter as being for the Xiangqi. When writing my last post, I missed the word “latter” and assigned the Xiangqi to the wrong move. Wikipedia did not mention the Ferz, which led to my confusion on the moves. I have never played the other ancient chess-like games, so I am unfamiliar with their pieces and moves. So I should have said….Harm’s Ferz move – one space diagonally and then one space orthogonally.

I will definitely take your comment to heart about not giving choices to the players for how the Knight moves and leave it as it currently is – the “L” shaped move. That will save a lot of editing of the rules, keep coding at a minimum, and keep the Knight stay at its strongest.

I never have liked en-passant because it seems like a rule that goes against what would happen in medieval battle – if a warrior runs past an enemy warrior on the battlefield, the one being passed would not yell out an order “Hey, you did not give me a chance to kill you, so come back here and let me behead you with my sword.” He would surely only get a medieval gesture similar to the ‘bird’. I want to keep my games as true to a medieval war as I can. However, I know that many chess purists feel that en-passant has a place in chess. That is why in my rules for Castle Siege Chess, I say that the players must agree at the beginning of the game whether or not they are going to use the en-passant rule. In the electronic version, I will make it a definite part of the game. The main audience for Castle Siege Chess is chess players, so I don’t want to create any friction with any of them by completely ignoring the en-passant rule.

For my other board games (Castle Action Chess, Castle Attack Chess, and Castle Challenge Chess), which I want to have turned into electronic games later, I am trying to appeal to both table top game players and chess players who don’t mind (or may even enjoy) mixing in some elements of chance when playing chess.

Your comment about my rule for castling is also good. I was trying to indicate that castling in Castle Siege Chess works as normal because for a King-side castle, the King move toward the Rook to the starting position of the Knight and then the Rook is moved over the King to the starting position of the Bishop, which are the same things that happen in traditional chess. And for the Queen-side castle, the King moves toward the Rook and is placed on the starting position of the Bishop and then the Rook is moved over the King to the starting position of the Queen, which also are the same ending positions in traditional chess. So I will take your advice and edit my rules castling description to hopefully be more clear.

So thanks Evert. I feel like you are helping a lot and I definitely appreciate it. For the past 4 years, I have been heavily play-testing my games at many chess clubs. The reception has been very good. Without any advertising, other than having an Etsy.com site, I have sold 54 games (including both online sales and in person sales). I starting to have a lot of confidence about eventually having a Kickstarter. But I think it is very important that I first have Castle Siege Chess playable online (or as a compter app that can also be played online). So there is still a lot of work to be done.

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

### Re: Chess engines for circular chess boards

Note that even an L description with only orthogonal steps (i.e. through cell edges) of the Knight move is ambiguous if you don't specify whether the short or long leg of the L has to be taken first. In the picture on your website you seem to mix these two moves: vertical (= forward or backward) moves start with the long leg, but sideway moves start with the short leg. This seems a very bad idea, because on this warped board it might not always be clear what is forward or sideways. (E.g. when you start in a triangle.) My advice: if you want to stick to the L-shape, require it to start with the long leg in all directions.

Something about Archer and Catapult is still not entirely clear to me: when you say they capture only at a distance of 2, you mean that they can move 1 or 3 squares only if the destination square is empty, and do not capture anything in that case? (As opposed to a Checkers-like capture.)

Like Evert says, the hard part will be to produce a GUI. When I mentioned Jocly, I only mentioned it as an example of a way to construct a move generator that would be able to handle such 'inhomogeneous' boards. I wouldn't want to suggest that it would be a good idea to implement your game in Jocly; it is a web interface, and the AI is very generic, and therefore rather weak. Still, Jocly is very general, and can do amazing things. Some variants with irregular boards have already been implemented, and could be used as a starting point:

http://hgm.nubati.net/jocly/jocly-maste ... ular-chess
http://hgm.nubati.net/jocly/jocly-maste ... ubic-chess