From 1dd78a565b7caff60f9369ff686b3aa0c8fd6f89 Mon Sep 17 00:00:00 2001 From: ianagbip1oti Date: Fri, 30 Aug 2024 15:20:21 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20NEW:=20Add=20hashful=20to=20info?= =?UTF-8?q?=20output?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/arena.rs | 6 +++++- src/search_tree.rs | 6 ++++-- src/transposition_table.rs | 11 ++++++++++- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/arena.rs b/src/arena.rs index d1ed89b..0c0decf 100644 --- a/src/arena.rs +++ b/src/arena.rs @@ -33,7 +33,11 @@ impl Arena { } } - pub fn full(&self) -> bool { + pub fn full(&self) -> usize { + self.owned_mappings.lock().unwrap().len() * 1000 / self.max_chunks + } + + pub fn is_full(&self) -> bool { let owned_mappings = self.owned_mappings.lock().unwrap(); owned_mappings.len() > self.max_chunks } diff --git a/src/search_tree.rs b/src/search_tree.rs index 68306a0..b5d5c1c 100644 --- a/src/search_tree.rs +++ b/src/search_tree.rs @@ -360,7 +360,8 @@ impl SearchTree { let new_node = match self.descend(&state, choice, tld) { Ok(r) => r, Err(ArenaError::Full) => { - self.ttable.flip_if_full(|| self.root_node.clear_children_links()); + self.ttable + .flip_if_full(|| self.root_node.clear_children_links()); return true; } }; @@ -499,12 +500,13 @@ impl SearchTree { let eval = eval_in_cp(edge.reward().average as f32 / SCALE); let info_str = format!( - "info depth {} seldepth {} nodes {} nps {} tbhits {} score {} time {} multipv {} pv {}", + "info depth {} seldepth {} nodes {} nps {} tbhits {} hashful {} score {} time {} multipv {} pv {}", depth.max(1), sel_depth.max(1), nodes, nps, self.tb_hits(), + self.ttable.full(), eval, search_time_ms, idx + 1, diff --git a/src/transposition_table.rs b/src/transposition_table.rs index b7d5068..eefe1bc 100644 --- a/src/transposition_table.rs +++ b/src/transposition_table.rs @@ -35,6 +35,11 @@ impl TranspositionTable { Self { table, arena } } + #[must_use] + pub fn full(&self) -> usize { + self.arena.full() + } + #[must_use] pub fn arena(&self) -> &Arena { &self.arena @@ -109,6 +114,10 @@ impl LRTable { Self::new(TranspositionTable::empty(), TranspositionTable::empty()) } + pub fn full(&self) -> usize { + (self.left.arena().full() + self.right.arena().full()) / 2 + } + pub fn insert<'a>(&'a self, key: &State, value: &'a PositionNode) -> &'a PositionNode { self.current_table().insert(key, value) } @@ -170,7 +179,7 @@ impl LRTable { { let _lock = self.flip_lock.lock().unwrap(); - if self.current_table().arena().full() { + if self.current_table().arena().is_full() { self.flip_tables(); f(); }