-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Early termination caused by castling #982
Comments
Hi, Thank you for sending a PR! 😄 I really appreciate it 🙏 Could you kindly add a test case in which the current implementation fails but the PR works? 🙏 🥺 We collect buggy test cases here: |
Thanks! I've added a test in https://github.com/sotetsuk/pgx/blob/main/tests/test_chess.py#L659 |
This is because actions = legal_norml_moves(
state._possible_piece_positions[0]
).flatten() # include -1 but note that as actions = legal_norml_moves(
jnp.arange(64)
).flatten() # include -1 So even if actually there are no pieces in some |
#983 is merged. I'll close this issue after a new pgx version is released. |
Thanks for the clarification. That makes sense! |
Hi Sotetsu,
I found an issue with both kingside and queenside castling in chess when I was playing with some games on Lichess. The problem is the games are always early terminated due to illegal actions after castling. I dived into the code and found the problem is probably in the
_apply_move
function (line 318).The original implementation only changed
state._board
but notstate._possible_piece_positions
after castling. Although, each move updatesstate._possible_piece_positions
here:due to the fact that castling is a move that involves two submoves, the position of the Rook should also be updated. Otherwise, this part
would be affected when checking legal moves.
I also have a question about the variable
state._possible_piece_positions
. When a piece is captured, the position of the piece will remain the same or should be set as a new value, like -1.Also, a minor typo is corrected at line 65 in chess.py
Thanks
The text was updated successfully, but these errors were encountered: