Open pavolkacej opened 2 years ago
I think I use board.mirror() so that the board is always from White's perspective, and therefore we always take metrics from white's point of view. However you may be right that this isn't properly implemented. If you think there are still problems, feel free to make a pr.
Hi @goshawk22 I am currently implementing my own chess based on alpha zero from https://github.com/suragnair/alpha-zero-general I just found your repository link there.
Just a friendly reminder - I found some issues in your implementation. It looks like you are never working with player type, that is passed to ChessGame logic. For example function
getGameEnded()
.I understand your idea, however it is more tricky to implement that, as we are not only checking, who won, but it is also important, which player is asking this question (if player 1 is passed to the argument, or player -1). However, you return the same output for both cases. See references to the function here:
You can see for example how Othello is implementing this: https://github.com/suragnair/alpha-zero-general/blob/master/othello/OthelloGame.py
Another thing to consider, is that you are creating mirrored version of the board always - but we want to mirror it only if player is -1. You can see more details in documentation https://github.com/suragnair/alpha-zero-general/blob/master/Game.py#L82 Also, board.mirror() function from chess package does not revert color of every piece (as we expect), but it seems to be do following:
Maybe it can work for our purpose, but I can see that Othello is reverting color for every piece, rather than this transformation.
In
getNextState()
, you are returning board.mirror(). Othello implementation does not do that.To sum up, you have got a nice ideas how to implement this (like doing board.copy() before pushing new move), but it need some more work to really see results. I believe it is still computationally slow to do the training process for chess, but this code needs to be more correct in my opinion. It needs some debugging. For example, you can check that there are cases, when board.turn is 1 (white to move), but player type from parameter is -1. These cases may happen, and it is important to think what to do in this case.
Thanks