diff options
author | eug-vs <eugene@eug-vs.xyz> | 2024-01-22 01:30:47 +0100 |
---|---|---|
committer | eug-vs <eugene@eug-vs.xyz> | 2024-01-22 02:01:34 +0100 |
commit | 299c6d6dee96a50f9366955192f922d449d11f20 (patch) | |
tree | db03f75fc611fcc409af9981c25c8373ed6d7b95 /src/grossmeister/ttable.rs | |
parent | f266b20fd559b624fc265905af4e7d971491915a (diff) | |
download | chessnost-299c6d6dee96a50f9366955192f922d449d11f20.tar.gz |
feat: store PV in a separate table
Diffstat (limited to 'src/grossmeister/ttable.rs')
-rw-r--r-- | src/grossmeister/ttable.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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 { |