feat: quiescence search

examines all captures using the new movegen, plus static exchange eval
This commit is contained in:
dogeystamp 2024-12-23 21:28:04 -05:00
parent cc40fb9a31
commit 795c2c508d
No known key found for this signature in database
2 changed files with 11 additions and 12 deletions

View File

@ -16,7 +16,7 @@ Copyright © 2024 dogeystamp <dogeystamp@disroot.org>
pub use crate::coordination::{ pub use crate::coordination::{
GoMessage, MsgBestmove, MsgToEngine, MsgToMain, UCIMode, UCIModeMachine, UCIModeTransition, GoMessage, MsgBestmove, MsgToEngine, MsgToMain, UCIMode, UCIModeMachine, UCIModeTransition,
}; };
pub use crate::eval::{eval_metrics, Eval, EvalInt, EvalMetrics}; pub use crate::eval::{eval_metrics, Eval, EvalInt, EvalMetrics, EvalSEE};
pub use crate::fen::{FromFen, ToFen}; pub use crate::fen::{FromFen, ToFen};
pub use crate::movegen::{FromUCIAlgebraic, GenAttackers, Move, MoveGen, ToUCIAlgebraic}; pub use crate::movegen::{FromUCIAlgebraic, GenAttackers, Move, MoveGen, ToUCIAlgebraic};
pub use crate::search::{ pub use crate::search::{

View File

@ -124,7 +124,7 @@ impl Default for SearchConfig {
alpha_beta_on: true, alpha_beta_on: true,
// try to make this even to be more conservative and avoid horizon problem // try to make this even to be more conservative and avoid horizon problem
depth: 10, depth: 10,
qdepth: 1, qdepth: 2,
enable_trans_table: true, enable_trans_table: true,
transposition_size: 24, transposition_size: 24,
} }
@ -234,10 +234,12 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec<M
// our best is their worst // our best is their worst
let beta = mm.beta.unwrap_or(EVAL_BEST); let beta = mm.beta.unwrap_or(EVAL_BEST);
let mut mvs: Vec<_> = board let mvs = if mm.quiesce {
.gen_moves() board.gen_captures().into_iter().collect::<Vec<_>>()
.into_iter() } else {
.collect::<Vec<_>>() board.gen_moves().into_iter().collect::<Vec<_>>()
};
let mut mvs: Vec<_> = mvs
.into_iter() .into_iter()
.map(|mv| (move_priority(board, &mv, state), mv)) .map(|mv| (move_priority(board, &mv, state), mv))
.collect(); .collect();
@ -266,14 +268,11 @@ fn minmax(board: &mut Board, state: &mut EngineState, mm: MinmaxState) -> (Vec<M
// determine moves that are allowed in quiescence // determine moves that are allowed in quiescence
if mm.quiesce { if mm.quiesce {
// use static exchange evaluation to prune moves
mvs.retain(|(_priority, mv): &(EvalInt, Move)| -> bool { mvs.retain(|(_priority, mv): &(EvalInt, Move)| -> bool {
if let Some(recap_sq) = board.recap_sq { let see = board.eval_see(mv.dest, board.turn);
if mv.dest == recap_sq {
return false;
}
}
false see > 0
}); });
} }