diff --git a/src/search/quiescence.rs b/src/search/quiescence.rs index 224bded..c036807 100644 --- a/src/search/quiescence.rs +++ b/src/search/quiescence.rs @@ -2,7 +2,11 @@ use anyhow::{bail, Result}; use crate::{board::game::Game, evaluation::pesto::pesto}; -use super::{move_ordering::score_move, time::TimeInfo}; +use super::{ + move_ordering::score_move, + time::TimeInfo, + transposition_table::{NodeType, TTEntry}, +}; pub fn quiescence( game: &mut Game, @@ -35,6 +39,7 @@ pub fn quiescence( let color = game.current_player(); let mut best_score = stand_pat; + let mut best_move = entry.and_then(|entry| entry.mv); let mut moves = game.board.pseudo_moves_all_captures(); moves.sort_unstable_by_key(|mv| { @@ -66,6 +71,7 @@ pub fn quiescence( if score > alpha { alpha = score; + best_move = Some(mv); } if score >= beta { @@ -73,5 +79,14 @@ pub fn quiescence( } } + let node_type = match best_score { + s if s >= beta => NodeType::LowerBound, + s if s <= alpha => NodeType::UpperBound, + _ => NodeType::Exact, + }; + + game.tt + .insert(TTEntry::new(game.hash, best_move, 0, best_score, node_type)); + Ok(best_score) }