You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
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
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
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?
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
andis_legal
to match this behavior.)It's impossible to check for 3-fold repetition in
is_game_over
given the way theChess
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)
The text was updated successfully, but these errors were encountered: