From 299c6d6dee96a50f9366955192f922d449d11f20 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Mon, 22 Jan 2024 01:30:47 +0100 Subject: feat: store PV in a separate table --- src/grossmeister/ttable.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/grossmeister/ttable.rs') diff --git a/src/grossmeister/ttable.rs b/src/grossmeister/ttable.rs index b1eeec3..b40bac1 100644 --- a/src/grossmeister/ttable.rs +++ b/src/grossmeister/ttable.rs @@ -62,8 +62,12 @@ impl TranspositionTable { #[derive(Debug, Default, Clone)] pub struct MasterTable { + /// Always contains the most recent transposition always_replace: TranspositionTable, + /// Stores highest-depth entries depth_preferred: TranspositionTable, + /// Used to collect Principal Variation. Not used in search + pv: TranspositionTable, } impl Grossmeister { @@ -81,6 +85,26 @@ impl Grossmeister { } { self.transposition_table.depth_preferred.set(self.board.hash, transposition) } + + // Store PV/Cut nodes in PV table + // Note: Cut nodes are probably only relevant in close-to-mate situations + if match transposition.node_type { + NodeType::PV => true, // Always replace PV nodes + NodeType::Cut => { + match self.transposition_table.pv.get(self.board.hash) { + Some(existing_transposition) => existing_transposition.node_type != NodeType::PV, + None => true, + } + } + _ => false, + } { + self.transposition_table.pv.set(self.board.hash, transposition) + } + } + + /// Extract current node information from PV table + pub fn pv(&self) -> Option<&TranspositionTableItem> { + self.transposition_table.pv.get(self.board.hash) } pub fn table_full(&self) -> u64 { -- cgit v1.2.3