Implement Index traits for Kind

This commit is contained in:
2024-07-16 21:52:14 +03:00
parent a1db302d0d
commit 1c80db695f
2 changed files with 39 additions and 20 deletions

View File

@@ -63,7 +63,7 @@ impl Board {
.update_castling_state_capture(mv.dst, Color::opponent_color(color));
self.state.change_side();
let own_king_square = lsb(pieces[Kind::King.idx()].bitboard);
let own_king_square = lsb(pieces[Kind::King].bitboard);
self.is_move_legit(own_king_square, Color::opponent_color(color))
}
@@ -138,10 +138,10 @@ impl Board {
fn promote_piece(square: usize, pieces: &mut [Piece; 6], promote: Promote) {
match promote {
Promote::Knight => pieces[Kind::Knight.idx()].bitboard |= square_to_bitboard(square),
Promote::Bishop => pieces[Kind::Bishop.idx()].bitboard |= square_to_bitboard(square),
Promote::Rook => pieces[Kind::Rook.idx()].bitboard |= square_to_bitboard(square),
Promote::Queen => pieces[Kind::Queen.idx()].bitboard |= square_to_bitboard(square),
Promote::Knight => pieces[Kind::Knight].bitboard |= square_to_bitboard(square),
Promote::Bishop => pieces[Kind::Bishop].bitboard |= square_to_bitboard(square),
Promote::Rook => pieces[Kind::Rook].bitboard |= square_to_bitboard(square),
Promote::Queen => pieces[Kind::Queen].bitboard |= square_to_bitboard(square),
};
}