aboutsummaryrefslogtreecommitdiff
path: root/src/grossmeister/search.rs
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2023-09-04 10:23:56 +0300
committereug-vs <eugene@eug-vs.xyz>2023-09-04 11:31:24 +0300
commit2f7a449038fb5dbc620e9f156c24bb6fa318d8fb (patch)
tree25b6e0442de4045531f575bf001ed173a2728562 /src/grossmeister/search.rs
parent870577620aebaa3011ca42c222a338d0eb0a07e0 (diff)
downloadchessnost-2f7a449038fb5dbc620e9f156c24bb6fa318d8fb.tar.gz
feat: define strict ordering between ttable items
Diffstat (limited to 'src/grossmeister/search.rs')
-rw-r--r--src/grossmeister/search.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/grossmeister/search.rs b/src/grossmeister/search.rs
index d0fddbb..23bcdfa 100644
--- a/src/grossmeister/search.rs
+++ b/src/grossmeister/search.rs
@@ -96,7 +96,6 @@ impl Grossmeister {
} else {
// After we have PV-node (that raised alpha) all other nodes will be searched
// with zero-window first to confirm this assumption
- // TODO: changing 0.001 -> 0.0001 leads to a weird bug
let score = self.negamax_search(-(alpha + 0.001), -alpha, depth_left - 1, root_distance + 1);
// In case some of the other nodes raises alpha, then it's true PV node now,
// let's research with full window to find its exact value
@@ -110,10 +109,10 @@ impl Grossmeister {
self.board.unmake_move(mov, captured_piece, ep_target_before, castling_rights_before, hash_before);
if score >= beta {
- self.transposition_table[(self.board.hash % TTABLE_SIZE) as usize] = Some(TranspositionTableItem {
+ self.store_transposition(TranspositionTableItem {
hash: self.board.hash,
mov,
- depth: depth_left, // TODO: should be actual depth searched
+ depth: depth_left,
node_type: NodeType::Cut,
score,
});
@@ -128,18 +127,18 @@ impl Grossmeister {
alpha = score;
should_pv_search = false; // Once we have PV-node we can start zero-window searching
- self.transposition_table[(self.board.hash % TTABLE_SIZE) as usize] = Some(TranspositionTableItem {
+ self.store_transposition(TranspositionTableItem {
hash: self.board.hash,
mov,
- depth: depth_left, // TODO: should be actual depth searched
+ depth: depth_left,
node_type: NodeType::PV,
score,
});
- } else if self.transposition().is_none() {
- self.transposition_table[(self.board.hash % TTABLE_SIZE) as usize] = Some(TranspositionTableItem {
+ } else {
+ self.store_transposition(TranspositionTableItem {
hash: self.board.hash,
mov,
- depth: depth_left, // TODO: should be actual depth searched
+ depth: depth_left,
node_type: NodeType::All,
score,
});
@@ -230,6 +229,7 @@ impl Grossmeister {
let mut pv = Vec::with_capacity(depth as usize);
if let Some(transposition) = self.transposition() {
+ debug_assert!(transposition.node_type == NodeType::PV);
let mov = transposition.mov;
let ep_target_before = self.board.ep_target;
let castling_rights_before = self.board.castling_rights;