aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2024-01-18 22:12:38 +0100
committereug-vs <eugene@eug-vs.xyz>2024-01-18 22:12:38 +0100
commitc101f2e230a2ed021ce54d6278ce120ad6d850fe (patch)
treeb2a94c6c20186176a82140b67325de6c9cfc537a /src
parentef1d62f64e3a52c371c29fea8cca400fde86a457 (diff)
downloadchessnost-c101f2e230a2ed021ce54d6278ce120ad6d850fe.tar.gz
fix: clamp score to keep it inside the window
Diffstat (limited to 'src')
-rw-r--r--src/grossmeister/search.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index 0ca5ef4..c195527 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -50,18 +50,20 @@ impl Grossmeister {
if let Some(transposition) = self.transposition() {
if transposition.depth >= depth_left {
match transposition.node_type {
- NodeType::PV | NodeType::Cut => {
+ NodeType::PV => {
+ return transposition.score.clamp(alpha, beta);
+ }
+ NodeType::Cut => {
if transposition.score >= beta {
- return beta
- }
- if transposition.score > alpha {
- alpha = transposition.score
+ return beta;
}
+ alpha = transposition.score.clamp(alpha, beta);
}
NodeType::All => {
if transposition.score <= alpha {
- return alpha
+ return alpha;
}
+ beta = transposition.score.clamp(alpha, beta);
}
}
}
@@ -171,18 +173,20 @@ impl Grossmeister {
if let Some(transposition) = self.transposition() {
match transposition.node_type {
- NodeType::PV | NodeType::Cut => {
+ NodeType::PV => {
+ return transposition.score.clamp(alpha, beta);
+ }
+ NodeType::Cut => {
if transposition.score >= beta {
- return beta
- }
- if transposition.score > alpha {
- alpha = transposition.score
+ return beta;
}
+ alpha = transposition.score.clamp(alpha, beta);
}
NodeType::All => {
if transposition.score <= alpha {
- return alpha
+ return alpha;
}
+ beta = transposition.score.clamp(alpha, beta);
}
}
}