From a1ad1424bcbf0fd8fff2ce9c4048e88a58934f20 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Wed, 25 Jan 2023 06:54:03 +0300 Subject: feat: check PV move first but not discard others --- src/board/engine.rs | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/board/engine.rs b/src/board/engine.rs index 6543d1d..2c6e47a 100644 --- a/src/board/engine.rs +++ b/src/board/engine.rs @@ -113,18 +113,19 @@ impl Board { let mut principal_variation = Vec::new(); let color = self.color(); - let moves = match transposition { - Some(item) => { - - if item.node_type == NodeType::PV && item.depth >= depth_left { - // println!("Cache hit (depth_left={}): {:?}", depth_left, item); - vec![item.best_move] - } else { - self.generate_pseudolegal_moves(color) + let mut moves = self.generate_pseudolegal_moves(color); + + if transposition.is_some() { + match transposition { + Some(item) => { + if item.node_type == NodeType::PV { + // println!("Cache hit at depth {}: {:?}", depth_left, item); + moves.insert(0, item.best_move); + } } + None => panic!("Unreachable"), } - None => self.generate_pseudolegal_moves(color), - }; + } if depth_left == 0 { return (self.evaluate(Some(moves.len() as f32)), principal_variation); -- cgit v1.2.3