Closed fredhope2000 closed 4 years ago
A move like Q@f3
is not legal unless there is also [Variant "Crazyhouse"]
. Then it should work fine and is already supported.
Ah, and I imagine the game needs to follow Crazyhouse rules (i.e., a piece can't be dropped unless the person has captured that piece from their opponent) in order to save properly? I tried adding an arbitrary Q@f3
onto the end of a blank game, but as soon as I set the [Variant "Crazyhouse"]
in the headers, I started getting KeyError: 5
(having to do with the queen being placed) when trying to do anything with the game.
e.g.:
game = chess.pgn.Game()
game.end().add_variation(chess.Move.from_uci('Q@f3'))
print(game) # this works, has 1. Q@f3
game.headers['Variant'] = 'Crazyhouse'
print(game) # now it blows up
Context is I'm using this library to implement bughouse (and I'm tracking the pieces separately), so it may think my game is impossible as recorded.
I'll close this issue as I didn't realize it already worked when the Variant is set (and my new problem is sort of unrelated and not really a flaw in this package).
A
Game
object is able to accept a drop move (e.g.game.end().add_variation(chess.Move.from_uci('Q@f3'))
) and this can be saved in the PGN. However, the PGN parser is unable to read this move when reading from PGN. It errors with "invalid san" because theSAN_REGEX
doesn't include the @ notation as a possibility: https://github.com/niklasf/python-chess/blob/29d1a27bbece06c3df529ee844e5b381fb386269/chess/__init__.py#L382Are there plans to support this?