summaryrefslogtreecommitdiff
path: root/src/claude-player.rs
diff options
context:
space:
mode:
authorDylan <boss@tehbox.org>2026-10-23 19:40:00 +1300
committerDylan <boss@tehbox.org>2026-10-23 19:41:07 +1300
commit8b6323efba32da9e3651ce882c02a6e7a6671f23 (patch)
tree3b01f4d47176379df2aadbef0ffc621a2d9d6186 /src/claude-player.rs
parent50028fc708ef0cfea9fd589c90e07b413ecb570f (diff)
downloadtigers-and-sheep-8b6323efba32da9e3651ce882c02a6e7a6671f23.tar.gz
tigers-and-sheep-8b6323efba32da9e3651ce882c02a6e7a6671f23.zip
feat: Optimisation
Added benchmarking capabilities
Diffstat (limited to 'src/claude-player.rs')
-rw-r--r--src/claude-player.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/claude-player.rs b/src/claude-player.rs
index 92be85b..5cbd794 100644
--- a/src/claude-player.rs
+++ b/src/claude-player.rs
@@ -1,6 +1,6 @@
-use std::{collections::HashMap, time::Duration};
+use std::time::Duration;
-use crate::{board::{is_jump, GameBoard, Move, PieceType, Turn}, player::{CacheEntry, MinimaxPlayer, SearchReport}};
+use crate::{board::{is_jump, GameBoard, Move, PieceType, Turn}, player::{Killers, MinimaxPlayer, SearchReport, TranspositionTable}};
/// Sheep that start the game: on the board plus in hand.
const TOTAL_SHEEP: u32 = 20;
@@ -9,7 +9,10 @@ const TOTAL_SHEEP: u32 = 20;
pub struct ClaudePlayer
{
pub time_limit: Duration,
- cache: HashMap<(GameBoard, Turn, usize), CacheEntry>,
+ /// The most plies to search, counting the move itself; normally `time_limit` stops the search first.
+ pub max_depth: usize,
+ cache: TranspositionTable,
+ killers: Killers,
last_search: Option<SearchReport>,
}
@@ -17,7 +20,7 @@ impl Default for ClaudePlayer
{
fn default() -> Self
{
- Self { time_limit: Duration::from_secs(1), cache: HashMap::new(), last_search: None }
+ Self::new(Duration::from_secs(1))
}
}
@@ -25,7 +28,7 @@ impl ClaudePlayer
{
pub fn new(time_limit: Duration) -> Self
{
- Self { time_limit, cache: HashMap::new(), last_search: None }
+ Self { time_limit, max_depth: 64, cache: TranspositionTable::new(20), killers: Killers::default(), last_search: None }
}
}
@@ -70,9 +73,13 @@ impl MinimaxPlayer for ClaudePlayer
fn time_limit(&self) -> Duration { self.time_limit }
+ fn depth(&self) -> usize { self.max_depth }
+
fn cache(&mut self) -> Option<&mut dyn crate::player::ScoreCache> {
Some(&mut self.cache)
}
+
+ fn killers(&mut self) -> Option<&mut Killers> { Some(&mut self.killers) }
}
#[cfg(test)]