Skip to content
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

Detect draws by 50-move-rule (and possibly 3-fold repetition) #24

Open
mateon1 opened this issue Jan 1, 2019 · 2 comments
Open

Detect draws by 50-move-rule (and possibly 3-fold repetition) #24

mateon1 opened this issue Jan 1, 2019 · 2 comments

Comments

@mateon1
Copy link

mateon1 commented Jan 1, 2019

Currently, is_game_over only detects checkmates, stalemates, and insufficient material, but not draws by the 50 move rule, or by 3-fold repetition.

Implementing the 50 move rule should be trivial, as the Chess struct keeps track of the halfmoves counter.
(should also probably change legal_moves and is_legal to match this behavior.)

It's impossible to check for 3-fold repetition in is_game_over given the way the Chess struct is implemented, but maybe it's possible to expose a separate API, that given a starting position and a list of moves, returns whether any position repeated three times.
(I'm sure there's a better solution than keeping a hashmap of board FENs since the last irreversible move)

@Mk-Chan
Copy link

Mk-Chan commented Jan 1, 2019

Technically the FIDE rules state that a draw is only forced at 75 reversible moves (if not check mate at the final move) and if the same position has appeared 5 times on consecutive alternative moves.

Article 9.6

@niklasf niklasf changed the title is_game_over: Detect draws by 50-move-rule (and possibly 3-fold repetition). Detect draws by 50-move-rule (and possibly 3-fold repetition) Oct 7, 2021
@niklasf
Copy link
Owner

niklasf commented Oct 7, 2021

With ZobristHash from #40 we now have a useful building block.

Nonetheless I am hesitating on this one, because it requires adding a representation for games (rather than just position), and it seems the best structure is application dependent. Should it be a stack? Should it be a tree? Only the final position with some book keeping?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants