niklasf / python-chess

A chess library for Python, with move generation and validation, PGN parsing and writing, Polyglot opening book reading, Gaviota tablebase probing, Syzygy tablebase probing, and UCI/XBoard engine communication
https://python-chess.readthedocs.io/en/latest/
GNU General Public License v3.0
2.42k stars 530 forks source link

Question can_claim_fifty_moves not indicating right to claim after 49 such moves #632

Closed dlbbld closed 4 years ago

dlbbld commented 4 years ago

Hi

By the rules, when having played 49 moves without capture or pawn move, and there is a possible further move without capture or pawn move, the player on the move can request the draw. But the can_claim_fifty_moves method returns false after 49 moves without capture or pawn move.

For the threefold repetition, the right to claim one move before the threefold repetition could occur is implemented. So the behaviour of the fifty move rule looks like a bug.

See the attached script and PGN's:

For "example_ending_with_fifty_moves_without_capture_and_pawn_move.pgn" the output is: After 55...Bg5 can claim threefold = False, can claim fifty = False After 56.Bc1 can claim threefold = False, can claim fifty = False After 56...Nd6 can claim threefold = False, can claim fifty = True

The expected output is: After 55...Bg5 can claim threefold = False, can claim fifty = False After 56.Bc1 can claim threefold = False, can claim fifty = True After 56...Nd6 can claim threefold = False, can claim fifty = True

For "example_ending_with_threefold_repetition.pgn" the output is as expected: After 3...Nf6 can claim threefold = False, can claim fifty = False After 4.Ng1 can claim threefold = True, can claim fifty = False After 4...Ng8 can claim threefold = True, can claim fifty = False

example_ending_with_fifty_moves_without_capture_and_pawn_move.pgn.txt example_ending_with_threefold_repetition.pgn.txt test_can_claim.py.txt

Please have a look.

niklasf commented 4 years ago

Indeed.

(§9.3) The game is drawn, upon a correct claim by the player having the move, if: (a) he writes his move on his scoresheet and declares to the arbiter his intention tomake this move, which shall result in thelast50 moves having been made by each player without the movement of any pawn and without any capture, or (b) the last 50 consecutive moves have been made by each playerwithout the movement of any pawn and without any capture.

-- https://www.fide.com/FIDE/handbook/LawsOfChess.pdf

dlbbld commented 4 years ago

Yes, that is the corresponding rule section. Just in case, FIDE does not maintain the current rules under the link https://www.fide.com/FIDE/handbook/LawsOfChess.pdf; though would make sense. The PDF contains the rules introduced 1 July 2009. That is why e.g. the PDF does not contain the fivefold repetition and seventy-five-move rule yet. The latest version for example is here: https://handbook.fide.com/chapter/E012018

Why is the issue now closed as taken up as bug? Is this taken up separately?

niklasf commented 4 years ago

Thanks for the link. It's fixed in the latest development version (1064bf5).

dlbbld commented 4 years ago

Yes, thanks, did not notice the fix. Thanks for taking this up.

niklasf commented 4 years ago

Fix included in v1.0.0.