summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-11-09 16:17:04 +1300
committerDylan <boss@tehbox.org>2026-11-09 16:17:04 +1300
commit0fd43eb6d9a4bae8d4c29fd614f9cf2a362f7b7c (patch)
treeeb926ba3fbc0dcde9717509e9fa02cc79a3679f9 /src/main.rs
parent046969c820e89b74d55c2d07c47470237f11cc2a (diff)
downloadtigers-and-sheep-0fd43eb6d9a4bae8d4c29fd614f9cf2a362f7b7c.tar.gz
tigers-and-sheep-0fd43eb6d9a4bae8d4c29fd614f9cf2a362f7b7c.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs9
1 files changed, 6 insertions, 3 deletions
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(())
}