Refactor time info, update zobrist to tuple struct, naming and clippy

This commit is contained in:
stefiosif
2025-01-26 20:16:01 +02:00
parent 36aa30ea17
commit 53beda7fe3
11 changed files with 78 additions and 77 deletions

View File

@@ -6,10 +6,9 @@ pub fn score_move(mailbox: &Mailbox, mv: Move, tt_move: Option<Move>) -> i32 {
}
let aggressor = mailbox.piece_at(mv.src).expect("No aggressor found.");
match mailbox.piece_at(mv.dst) {
Some(victim) => aggressor.0.idx() as i32 - (victim.0.idx() * 8) as i32,
None => 100,
}
mailbox.piece_at(mv.dst).map_or(100, |victim| {
aggressor.0.idx() as i32 - (victim.0.idx() * 8) as i32
})
}
#[cfg(test)]
@@ -35,7 +34,6 @@ mod tests {
assert_eq!(moves, vec![pawn_takes_queen, queen_takes_pawn, castle]);
let castle = Move::with_type(Square::E1, Square::C1, MoveType::Castle);
moves.sort_unstable_by_key(|mv| score_move(&game.mailbox, *mv, Some(castle)));
assert_eq!(moves, vec![castle, pawn_takes_queen, queen_takes_pawn]);