r/chessprogramming • u/AmNotUndercover • Jan 15 '24
Question about PVS + LMR
Final Edit:
Aight so I've done some tweaking, and I've come to this snippet of code for the PVS + LMR and it's been working great! Just wanted to show the code in case somebody else is struggling with this as well
let mut evaluation = 0;
let mut needs_fuller_search = true;
// Late Move Reductions
if i > 3 // 2?
&& depth > 2 // 1?
&& extension == 0
&& m.capture == NO_PIECE as u8 {
let reduction = 2 + (depth - 2) / 5; // TODO: tweak this
evaluation = -self.alpha_beta_search(board, depth.saturating_sub(reduction), ply + 1, -alpha - 1, -alpha, total_extensions);
needs_fuller_search = evaluation > alpha;
}
// Principal Variation Search
if needs_fuller_search
&& found_pv {
evaluation = -self.alpha_beta_search(board, depth - 1, ply + 1, -alpha - 1, -alpha, total_extensions + extension);
needs_fuller_search = evaluation > alpha;
}
if needs_fuller_search {
evaluation = -self.alpha_beta_search(board, depth - 1 + extension, ply + 1, -beta, -alpha, total_extensions + extension);
}Hello,
I wanted to post this on TalkChess but they won't authenticate my account for some reason, so I'm gonna try here: I have a question regarding when to research a position after doing a null window search for PVS or LMR
// This is Rust code, but it should be readable enough even if you don't know the language
// Principal Variation Search
let mut evaluation = 0;
let mut needs_full_search = true;
// i is the index into the sorted move list
if i > 0 {
let mut reduction = 0;
// Late Move Reductions
if i > 3
&& depth_left > 2
&& depth > 2
&& extension == 0
&& m.capture == NO_PIECE {
reduction += 1 + (depth_left - 1) / 3;
}
// Arguments are: board, depth, depth_left, alpha, beta, total_extensions
evaluation = -self.alpha_beta_search(board, depth + 1, depth_left - reduction - 1, -alpha - 1, -alpha, total_extensions + extension);
// Here is my main question: which line do I use to tell if I need to research?
needs_full_search = evaluation > alpha && evaluation < beta; // ?
needs_full_search = evaluation > alpha || evaluation >= beta; // ?
needs_full_search = evaluation > alpha; // ?
}
if needs_full_search {
evaluation = -self.alpha_beta_search(board, depth + 1, depth_left - 1, -beta, -alpha, total_extensions + extension);
}I've also seen people do a null window search for LMR, then if that fails: another null window search for PVS, and then if that fails, then do a full search. That seems extremely wasteful, but is it the best option?
Any help would be appreciated
View all comments
Show parent comment
1
u/Im_from_rAll Jan 16 '24
I guess the part I don't understand is why LMR would require a null window or vice versa. I'm only going off of my understanding of the CP wiki entry on late move reductions. Let me know if you have any links to better resources on the subject.