···190190191191/// Returns the current game state: A win, draw or neither.
192192pub fn state(game: Game) -> GameState {
193193- // TODO: Check for insufficient material and threefold repetition
193193+ // TODO: Check for insufficient material
194194 use <- bool.guard(game.half_moves >= 50, Draw(FiftyMoves))
195195+ // We count two-fold repetition
196196+ use <- bool.guard(
197197+ game.is_threefold_repetition(game),
198198+ Draw(ThreefoldRepetition),
199199+ )
195200 use <- bool.guard(move.any_legal(game), Continue)
196201 use <- bool.guard(!game.attack_information.in_check, Draw(Stalemate))
197202 case game.to_move {