Remove tt cutoffs, fix capture move sorting, refactor
This commit is contained in:
@@ -2,10 +2,23 @@ use crate::{
|
||||
board::mailbox::Mailbox, evaluation::evaluation::material_score, movegen::r#move::Move,
|
||||
};
|
||||
|
||||
pub const fn mvv_lva(mailbox: &Mailbox, mv: Move) -> i32 {
|
||||
pub fn sort_moves(mut moves: Vec<Move>, mailbox: &Mailbox, tt_move: Option<Move>) -> Vec<Move> {
|
||||
if let Some(tt_move) = tt_move {
|
||||
if let Some(tt_move_index) = moves.iter().position(|&mv| mv == tt_move) {
|
||||
moves.remove(tt_move_index);
|
||||
moves.insert(0, tt_move);
|
||||
return moves;
|
||||
}
|
||||
}
|
||||
|
||||
moves.sort_unstable_by_key(|mv| std::cmp::Reverse(mvv_lva(mailbox, *mv)));
|
||||
moves
|
||||
}
|
||||
|
||||
const fn mvv_lva(mailbox: &Mailbox, mv: Move) -> i32 {
|
||||
match (mailbox.piece_at(mv.src), mailbox.piece_at(mv.dst)) {
|
||||
(Some(aggressor), Some(victim)) => material_score(victim) - material_score(aggressor),
|
||||
_ => 0,
|
||||
_ => -1000,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user