aboutsummaryrefslogtreecommitdiff
path: root/src/board
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-01-25 06:54:03 +0300
committereug-vs <eugene@eug-vs.xyz>2023-01-25 06:54:03 +0300
commita1ad1424bcbf0fd8fff2ce9c4048e88a58934f20 (patch)
tree5c497ad24d0b3661db3ac6cce9c48c539c950c65 /src/board
parentf6b3eae09ef3a8191c02cf462623032670cc5d13 (diff)
downloadchessnost-a1ad1424bcbf0fd8fff2ce9c4048e88a58934f20.tar.gz
feat: check PV move first but not discard others
Diffstat (limited to 'src/board')
-rw-r--r--src/board/engine.rs21
1 files changed, 11 insertions, 10 deletions
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);