Rename movegen module files and make readability improvements
This commit is contained in:
@@ -2,13 +2,14 @@ use crate::{board::board::Board, movegen::r#move::Move};
|
||||
|
||||
// Rows: Aggressors (P, N, B, R, Q, K)
|
||||
// Columns: Victims (K, Q, R, B, N, P)
|
||||
#[rustfmt::skip]
|
||||
const MVV_LVA: [[usize; 6]; 6] = [
|
||||
[30, 29, 28, 27, 26, 00],
|
||||
[25, 24, 23, 22, 21, 00],
|
||||
[20, 19, 18, 17, 16, 00],
|
||||
[15, 14, 13, 12, 11, 00],
|
||||
[10, 09, 08, 07, 06, 00],
|
||||
[05, 04, 03, 02, 01, 00],
|
||||
[30, 29, 28, 27, 26, 0],
|
||||
[25, 24, 23, 22, 21, 0],
|
||||
[20, 19, 18, 17, 16, 0],
|
||||
[15, 14, 13, 12, 11, 0],
|
||||
[10, 9, 8, 7, 6, 0],
|
||||
[5, 4, 3, 2, 1, 0],
|
||||
];
|
||||
|
||||
pub fn score_by_mvv_lva(board: &Board, mv: Move) -> usize {
|
||||
|
||||
@@ -63,7 +63,7 @@ pub fn negamax(
|
||||
mod tests {
|
||||
use crate::board::{fen::from_fen, square::Square};
|
||||
use crate::evaluation::{MAX_SCORE, MIN_SCORE};
|
||||
use crate::movegen::attack::init_attacks;
|
||||
use crate::movegen::attack_generator::init_attacks;
|
||||
use crate::movegen::r#move::Move;
|
||||
use crate::search::negamax::negamax;
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ pub fn _square_to_notation(square: u8) -> &'static str {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{board::fen::from_fen, movegen::attack::init_attacks};
|
||||
use crate::{board::fen::from_fen, movegen::attack_generator::init_attacks};
|
||||
|
||||
use super::driver;
|
||||
|
||||
|
||||
@@ -18,12 +18,17 @@ pub fn quiescence(game: &mut Game, mut alpha: i32, beta: i32) -> (Option<Move>,
|
||||
alpha = stand_pat;
|
||||
}
|
||||
|
||||
let mut captures: Vec<_> = game.board.pseudo_moves_all().into_iter().filter(|m| {
|
||||
matches!(
|
||||
m.move_type,
|
||||
MoveType::Capture | MoveType::PromotionCapture(_)
|
||||
)
|
||||
}).collect();
|
||||
let mut captures: Vec<_> = game
|
||||
.board
|
||||
.pseudo_moves_all()
|
||||
.into_iter()
|
||||
.filter(|m| {
|
||||
matches!(
|
||||
m.move_type,
|
||||
MoveType::Capture | MoveType::PromotionCapture(_)
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
||||
captures.sort_unstable_by_key(|mv| score_by_mvv_lva(&game.board, *mv));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user