From bbeb1b8b37e8ff40e5422009481a4a909e3936f9 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Wed, 26 Feb 2025 19:50:40 -0500 Subject: [PATCH] aa --- Cargo.toml | 6 ++---- src/complexagent.rs | 2 +- src/logic/future_moves.rs | 12 +++++++----- src/logic/move.rs | 1 - src/main.rs | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ce0ed3c..fc1a739 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,6 @@ path = "src/lib.rs" name = "othello_game" path = "src/main.rs" - [profile.release] # increases perf at the cost of compile-time codegen-units = 1 # ~4-5% perf bump @@ -22,7 +21,6 @@ inherits = "release" # for profiling debug = true - [features] bitvec = [ "dep:bitvec" ] @@ -33,13 +31,13 @@ const_fn = "0.4" either = "1.13" indicatif = "0.17" lazy_static = "1.5" -nohash-hasher = "0.2.0" +nohash-hasher = "0.2" num = "0.4" rand = "0.9" static_assertions = "1.1" [dev-dependencies] -criterion = { version = "0.5", features = ["html_reports"] } +criterion = { version = "0.5", features = [ "html_reports" ] } [[bench]] name = "future_children" diff --git a/src/complexagent.rs b/src/complexagent.rs index d8bfed8..633239d 100644 --- a/src/complexagent.rs +++ b/src/complexagent.rs @@ -13,7 +13,7 @@ pub struct ComplexAgent { impl ComplexAgent { pub const fn new(color: Piece) -> Self { const CONFIG: FutureMoveConfig = FutureMoveConfig { - max_depth: 9, + max_depth: 10, start_pruning_at_minus: 4, top_k_children: 2, up_to_mod: 4, diff --git a/src/logic/future_moves.rs b/src/logic/future_moves.rs index a41f5a6..eb361b5 100644 --- a/src/logic/future_moves.rs +++ b/src/logic/future_moves.rs @@ -263,14 +263,16 @@ impl FutureMoves { /// Returns a boolean, `true` if the operation was successful, false if not #[must_use = "You must check if the root was properly set"] pub fn update_root_coord(&mut self, i: usize, j: usize) -> bool { + // check to make sure current_root is some so we dont + // have to do that in the iterator + if self.current_root.is_none() { + return false; + } + self.arena .iter() .enumerate() - .find(|(_, node)| { - node.parent == self.current_root - && self.current_root.is_some() - && node.coords() == (i, j) - }) + .find(|(_, node)| node.parent == self.current_root && node.coords() == (i, j)) .map(|x| x.0) // do raw set so we can prune it on the next move (in `update`) .inspect(|&root| self.update_root_idx_raw(root)) diff --git a/src/logic/move.rs b/src/logic/move.rs index 0b3a2ef..5fff678 100644 --- a/src/logic/move.rs +++ b/src/logic/move.rs @@ -54,7 +54,6 @@ impl Move { self_value: 0, }; m.self_value = m.compute_self_value(agent_color); - m.value = Some(m.self_value as i128); m } diff --git a/src/main.rs b/src/main.rs index e6672a5..82924e5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,8 +10,8 @@ pub mod repr; fn main() { let player1 = complexagent::ComplexAgent::new(Piece::Black); // let player2 = complexagent::ComplexAgent::new(Piece::White); - // let player2 = agent::ManualAgent::new(Piece::White); - let player2 = agent::RandomAgent::new(Piece::White); + let player2 = agent::ManualAgent::new(Piece::White); + // let player2 = agent::RandomAgent::new(Piece::White); let mut game = Game::new(Box::new(player1), Box::new(player2)); game.game_loop(); }