From 0fd43eb6d9a4bae8d4c29fd614f9cf2a362f7b7c Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 9 Nov 2026 16:17:04 +1300 Subject: feat: Draw by threefold repetition A position coming up for the third time with the same side to move ends the game as a draw, in the TUI and in training self-play. Players now get the game's earlier boards in pick_move, and the search scores the first repetition on its path as a draw, so a side that is ahead avoids one and a side that is behind seeks one. Co-Authored-By: Claude Opus 5.5 --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index b6a4ad0..5a3c798 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::{path::PathBuf, time::Duration}; use clap::{Args, Parser, Subcommand, ValueEnum}; -use crate::{claude_player::ClaudePlayer, game::GameHandler, local_player::LocalPlayer, network::Network, neural_player::NeuralPlayer, player::Player}; +use crate::{board::Outcome, claude_player::ClaudePlayer, game::GameHandler, local_player::LocalPlayer, network::Network, neural_player::NeuralPlayer, player::Player}; mod board; mod player; @@ -218,9 +218,12 @@ fn play(args: PlayArgs) -> std::io::Result<()> let mut sheep = make_player(args.sheep, time_limit)?; let mut tiger = make_player(args.tiger, time_limit)?; let mut game = GameHandler::default(); - if let Some(winner) = game.play_game(sheep.as_mut(), tiger.as_mut())? + match game.play_game(sheep.as_mut(), tiger.as_mut())? { - println!("{winner:?} wins!"); + Some(Outcome::Tiger) => println!("Tigers win!"), + Some(Outcome::Sheep) => println!("Sheep win!"), + Some(Outcome::Draw) => println!("Draw by repetition."), + None => (), } Ok(()) } -- cgit v1.3.1