Closed sshivaji closed 9 years ago
Never mind, looks like calling status() after setting fen does the trick, might be worth making this happen by default
Yeah, error handling can sometimes be a difficult thing to get right.
It was easier not to automatically check the status after set_fen, because then it is very simple to keep the guarantee, that set_fen does not leave the board in a half updated state.
For example:
board = chess.Bitboard()
try:
board.set_fen("syntactically-invalid-fen")
except:
# Now the board is guaranteed to not have changed
pass
I'll keep this issue to look into this again sometime.
I also like that set_fen allows you to setup a position partially (useful for doing setup board). Maybe a separate process_fen(fen) method might be useful. This method can throw exceptions if there is something wrong.
This method might be eaiser than set_fen and then checking status() for any problems.
On Mon, Nov 24, 2014 at 8:43 AM, Niklas Fiekas notifications@github.com wrote:
Yeah, error handling can sometimes be a difficult thing to get right.
It was easier not to automatically check the status after set_fen, because then it is very simple to keep the guarantee, that set_fen does not leave the board in a half updated state.
For example:
board = chess.Bitboard() try: board.set_fen("invalid-fen") except:
Now the board is guaranteed to not have changed
pass
I'll keep this issue to look into this again sometime.
— Reply to this email directly or view it on GitHub https://github.com/niklasf/python-chess/issues/16#issuecomment-64222793.
Will close issue as there are more important things to address
I tried set_fen with only one king on the board and it passed validation. Looking at the code, this is not yet done. It would be useful to check if a fen is valid.
Use case: Setup position on a board and using python chess to verify that the position is valid.