niklasf/python-chess

This is a bug??? (but not a problem)

9acca9 opened this issue · 1 comments

I think that maybe, maybe... i found a bug???! or maybe not.

Well. I was using your module, it is pretty amazing.

But, i noticed this:
if you make any move NOT legal move with the King the module take it as CASTLING.
It could be possible or i have a problem in my code??
Of course you first could use chess_board.legal_moves to see if it is valid or not and avoid that problem.
But it seems weird to me because instead of create an error the module take it as a valid move and believe that is Castling.

This is the part of the code that get the castling:
(...)

if chess_board.is_castling(move): 
      print("This is my move ",move)
      logging.info("I make the castling!")

i just try this with white pieces, dont know what happens with black.
For example i play e2e4, e7e5... and after that white move e1g3!!! and it seems that the module believe that that is castling
``
imagen

where it says "Me enroquè" that is "i make the castling!" in spanish.
So, i dont know.
Thanks!

Of course, this is not a problem.
Thank you very much for your beautiful module!

Hi, thanks for reporting. What happens here is not a bug, but perhaps a bit surprising: Some methods have documented preconditions that are not checked for performance reasons.

For example board.is_castling():

Checks if the given pseudo-legal move is a castling move.

So the answer is only guaranteed to be valid if the move is pseudo-legal.