I am new to this forum, so firstly I'd like to say hello!
I like chess variants a lot. I had design a few myself and I am a constant presence on chessvariants.com website! I am now designing 4 new 10x10 variants. Here are the two games that are close to the ones I'm designing:
https://www.chessvariants.com/rules/apothecary-chess-2
https://www.chessvariants.com/rules/apothecary-chess-1
They are a combination of Omega Chess, Grand Chess and a few of my own ideas.
I want to make 4 engines to play these games. Each of those should be made with neural networks, somewhat alpha zero style. I have some experience in NN and I have learned the basics of python lately. I'm saying somewhat alpha zero because I'm aiming that the initial training will be made with games played by chessV against itself. Also the inputs I'm planning won't be so raw like in alpha zero but some elements of of strategy (like piece values) will be included.
I have not decided about the neural network architecture as I do not understand completely the feature extraction layers of the Alpha Zero network. I understand that they form a convolutional NN but I do not understand what filters it uses. If someone can explain that to me I'd be highly appreciative. I can also try a fully connected perceptron with regularization training like it is explained here:
https://www.oreilly.com/library/view/te ... /ch04.html
I'm also considering a radial basis network. That has not been done before and I'm not sure about it, but if there is something to say about it please do!
By the way, each of the games have a joker(imitator or fool)- a piece that does not have a move of it's own but inherits the last move of the opponent. That makes thing more complicated a bit.
Hello and my engine plans!
Moderators: chrisw, Rebel, Ras
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
-
- Posts: 28268
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Hello and my engine plans!
A very ambitious project. Perhaps you should start programming the search you want to use, and get it running with a simple hand-crafted evaluation (just piece values and centralization bonus should be good enough). And only when that works replace the evaluation by a neural network, and train it.
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
Re: Hello and my engine plans!
Thanks for your advice!
I'll do just that!
I'll do just that!
-
- Posts: 35
- Joined: Thu Mar 03, 2022 7:29 am
- Full name: Alvin Peng
Re: Hello and my engine plans!
Not sure if this answers your question, but AlphaZero used a ResNet, which is a type of deep convolutional neural network architecture used in image classification. Colored images are actually 3D tensors, having not only height and width, but depth as well. This depth comes from the fact that colored images are combinations of red, green and blue planes with dimensions HxW. These RGB planes are stacked on top of each other, resulting in a tensor of dimensions 3xHxW. This tensor can be fed into a CNN to be classified.catugocatugocatugo wrote: ↑Sun Feb 19, 2023 10:03 am I have not decided about the neural network architecture as I do not understand completely the feature extraction layers of the Alpha Zero network. I understand that they form a convolutional NN but I do not understand what filters it uses. If someone can explain that to me I'd be highly appreciative.
A chess position can be viewed as an image with HxW of 8x8. But instead of RGB planes, each piece can represent a different plane. You would have several one-hot encoded planes of dimensions 8x8 representing white pawns, black pawns, white knights, etc. This would give an "image" tensor of dimensions 12x8x8 for the 12 kinds of pieces. Additional planes are also needed to represent other features in a position such as castling rights. AlphaZero also used so-called "history planes", which involved stacking the tensors of several past positions on top of the current position, giving a tensor of Nx8x8. This tensor was then sent through the network to output a prediction for the best move and the value of the position.
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
Re: Hello and my engine plans!
The mention of ResNets led me to find this article: https://arxiv.org/pdf/1512.03385.pdf.Not sure if this answers your question, but AlphaZero used a ResNet, which is a type of deep convolutional neural network architecture used in image classification.
I'm confident this does the trick. Thanks!
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
Re: Hello and my engine plans!
I have read everything I could get my hands on the chess programming wiki.
I'm deciding now what the board board representation to use. I can't figure out which to use.
I'm inclined to maintain both a mailbox representation like the one in Sargon :
https://www.chessprogramming.org/10x12_Board
and also a bitboard representation for check detection.
Also the input of the neural network in Alpha Zero is a set of bitboards.
I don't have to do it the same, but I am unsure of straying to much out of the known path.
Bear in mind that my games have bent riders and a joker (imitator, fool).
May someone with more experience advice me a bit?
I'm deciding now what the board board representation to use. I can't figure out which to use.
I'm inclined to maintain both a mailbox representation like the one in Sargon :
https://www.chessprogramming.org/10x12_Board
and also a bitboard representation for check detection.
Also the input of the neural network in Alpha Zero is a set of bitboards.
I don't have to do it the same, but I am unsure of straying to much out of the known path.
Bear in mind that my games have bent riders and a joker (imitator, fool).
May someone with more experience advice me a bit?
-
- Posts: 28268
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Hello and my engine plans!
Speedwise bitboards are not really competitive for boards with more than 64 squares. But in Alpha-Zero-type programs the computational effort is completely dominated by the Neural Networks, and any method used for representing and updating the board, no matter how inefficient, will have no significant impact on the speed.
It is not simple to make an efficient dedicated method for check detection in the presence of pieces that can turn corners of hop over other pieces; checks cannot come only from the first piece in a limited number of directions, but from a large fraction of the board. So it might be better to base the search on pseudo-legal moves, and report a +INFINITE score when move generation encounters a King capture, to inform the parent node that the preceding move that was played there was illegal, and should never be searched again.
This might not be the fastest method, especially when you generatecheck evasions from a position where you are already in check. But since positions where the check was not resolved discover this before the NN is run on them, this will have no significant impact on the overall speead.
I would recommend a mailbox board according to 0x88 philosophy: make it twice as wide as high. In that case the difference of on-board square numbers are a unique signature for the move step, a property that can sometimes be useful. With narrower board there can be ambiguity between real moves and imaginary ones that cross the 'guard band' between left and right edge of the 2d board.
It is not simple to make an efficient dedicated method for check detection in the presence of pieces that can turn corners of hop over other pieces; checks cannot come only from the first piece in a limited number of directions, but from a large fraction of the board. So it might be better to base the search on pseudo-legal moves, and report a +INFINITE score when move generation encounters a King capture, to inform the parent node that the preceding move that was played there was illegal, and should never be searched again.
This might not be the fastest method, especially when you generatecheck evasions from a position where you are already in check. But since positions where the check was not resolved discover this before the NN is run on them, this will have no significant impact on the overall speead.
I would recommend a mailbox board according to 0x88 philosophy: make it twice as wide as high. In that case the difference of on-board square numbers are a unique signature for the move step, a property that can sometimes be useful. With narrower board there can be ambiguity between real moves and imaginary ones that cross the 'guard band' between left and right edge of the 2d board.
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
Re: Hello and my engine plans!
So you are saying something like this:I would recommend a mailbox board according to 0x88 philosophy: make it twice as wide as high. In that case the difference of on-board square numbers are a unique signature for the move step, a property that can sometimes be useful. With narrower board there can be ambiguity between real moves and imaginary ones that cross the 'guard band' between left and right edge of the 2d board.
[
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,
]
I don't understand here how the vertical offboard rook moves are detected.
I see at the conclusions of the article of 0x88 that:
That would mean for me a 20x20 board I guess. Also I don't understand why the "off the board condition" is almost redundant and not fully redundant!A combination of 0x88 and 10x12 Board with surrounded ranks, that is 16x12 or even 16x16 for a symmetric treatment of files and ranks (or 15x12, 15x15) seems slightly more efficient than pure 0x88 aka 16x8, making the "off the board" index condition almost redundant, since it can be combined with the coding of the guard or sentinal squares
-
- Posts: 28268
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: Hello and my engine plans!
I would use the principle of surrounding ranks for testing whether a move strays off board. If Camels participate you would need 3 ranks as guard band to catch their moves. For a 10x12 'physical' board you could then use a 20x18 layout. Like
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
where 1 indicates a 'boundary guard'. A small annoyance is that the square numbers would exceed 255, and thus would not fit in an 8-byte variable. To work around that you could start numbering (with 0) in the corner of a physical board, so that the lower guard band has negative square numbers (and the upper guard band numbers > 255). These off-board squares would never be referenced in a valid move, so you could still use 8-bit variables to indicate origin and destination in the move encoding or the hash table. They would only appear as intermediate results in your move generation, where using 32-bit integers for the square numbers does not hurt, when an off-board move is generated, and then rejected.
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
where 1 indicates a 'boundary guard'. A small annoyance is that the square numbers would exceed 255, and thus would not fit in an 8-byte variable. To work around that you could start numbering (with 0) in the corner of a physical board, so that the lower guard band has negative square numbers (and the upper guard band numbers > 255). These off-board squares would never be referenced in a valid move, so you could still use 8-bit variables to indicate origin and destination in the move encoding or the hash table. They would only appear as intermediate results in your move generation, where using 32-bit integers for the square numbers does not hurt, when an off-board move is generated, and then rejected.
-
- Posts: 15
- Joined: Thu Feb 16, 2023 12:56 pm
- Full name: Florea Aurelian
Re: Hello and my engine plans!
Well my board is actually 10x10 (I had gave up the brouhaha squares). The longest jump is indeed 3 (camel, frog so on). I was thinking about an 16x16 (=256) board (3 guards around) to keep pieces like in Sargon (there are 11 piece types here so the use of another bit is needed but this is not a problem as there were 2 unused bits anyway). It can even be 14 by 16 as a camel would exit 2 squares to the left and enter one square all on the other side. And then the full 0x88 board which is 20x16 for piece attacks and other 0x88 trick friendly things (I'm not really sure what I am talking about here yet).