chess-alpha-zero icon indicating copy to clipboard operation
chess-alpha-zero copied to clipboard

Issue with maybe_flip_fen method

Open simonMoisselin opened this issue 5 years ago • 5 comments

Hey, I am using part of your code for a personal project. I have seen an issue with the method maybe_flip_flen. I am not sure it is working correctly. The fundamental problem is that It's using the type of symmetry horizontal center mirror, instead of doing a 180-degree rotation, which is different.

In this image, I believe the knight should be on the top left part of the board instead of the top right.

image

simonMoisselin avatar Apr 10 '20 15:04 simonMoisselin

You're completely right from a chess game perspective, the 180 degree rotation is what you would do when looking at the same game from the other side of the board. However from the game state symmetry perspective, you want to "flip" black into a white-like position, so the neural network doesn't have to learn the same position once for black and once for white. In this case, you have to do the horizontal mirroring to get the kings on the right.

As a beside, it's unclear how much (if any) benefit this provides to the training algorithm, but it can't hurt so why not? ¯_(ツ)_/¯

Akababa avatar Apr 10 '20 16:04 Akababa

Good point!

simonMoisselin avatar Apr 10 '20 21:04 simonMoisselin

Does it mean that the model is making prediction only when this is WHITE to play?

simonMoisselin avatar Apr 10 '20 21:04 simonMoisselin

Yep, this was a while ago but IIRC we actually removed the one-hot color input.

Akababa avatar Apr 10 '20 23:04 Akababa

The more I think about it, and the 180-degree rotation needs to be done correctly, otherwise you will simulate games that does not make any senses? (they cannot corresponds to game in real life)

simonMoisselin avatar Apr 15 '20 14:04 simonMoisselin