Remove redundant PieceType params

This commit is contained in:
stefiosif
2024-10-06 11:32:39 +03:00
parent 3fd3b1ea96
commit 7f6cfb93a2
2 changed files with 15 additions and 42 deletions

View File

@@ -82,11 +82,8 @@ impl Game {
}
MoveType::EnPassant => {
board.move_piece(mv.src, mv.dst, piece_at_src);
let piece_at_capture = mailbox
.piece_at(capture_square)
.expect("Expected piece at: {capture_square}");
board.remove_opponent_piece(capture_square, PieceType::Pawn);
hash.update_en_passant(mv.src, mv.dst, piece_at_src, piece_at_capture, color);
hash.update_en_passant(mv.src, mv.dst, piece_at_src, color);
mailbox.set_piece_at(mv.dst, Some(piece_at_src));
mailbox.set_piece_at(capture_square, None);
}
@@ -96,36 +93,21 @@ impl Game {
Color::White => Some(mv.src + 8),
Color::Black => Some(mv.src.saturating_sub(8)),
};
hash.update_double_push(
mv.src,
mv.dst,
piece_at_src,
color,
board.state.en_passant_square,
);
hash.update_double_push(mv.src, mv.dst, color, board.state.en_passant_square);
mailbox.set_piece_at(mv.dst, Some(piece_at_src));
}
MoveType::Promotion(promote) => {
board.remove_own_piece(mv.src, piece_at_src);
board.promote_piece(mv.dst, promote);
hash.update_promotion(mv.src, mv.dst, piece_at_src, promote, color);
hash.update_promotion(mv.src, mv.dst, promote, color);
mailbox.set_piece_at(mv.dst, Some(promote.into_piece_type()));
}
MoveType::PromotionCapture(promote) => {
let piece_at_dst = piece_at_dst.expect("Expected piece at dst: {mv.dst}");
board.remove_own_piece(mv.src, piece_at_src);
board.remove_opponent_piece(
mv.dst,
piece_at_dst.expect("Expected piece at dst: {mv.dst}"),
);
board.remove_opponent_piece(mv.dst, piece_at_dst);
board.promote_piece(mv.dst, promote);
hash.update_promotion_capture(
mv.src,
mv.dst,
piece_at_src,
piece_at_dst.unwrap(),
promote,
color,
);
hash.update_promotion_capture(mv.src, mv.dst, piece_at_dst, promote, color);
mailbox.set_piece_at(mv.dst, Some(promote.into_piece_type()));
}
MoveType::Castle => {