Implement 'Default' for 'ChessBoard'
This commit is contained in:
parent
ce3ebf05ee
commit
c112ddc4cd
|
@ -1,4 +1,4 @@
|
|||
use super::{Bitboard, CastleRights, Color, File, Move, Piece, Square};
|
||||
use super::{Bitboard, CastleRights, Color, File, Move, Piece, Rank, Square};
|
||||
|
||||
/// Represent an on-going chess game.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
|
@ -179,3 +179,39 @@ impl ChessBoard {
|
|||
self.side = !self.side;
|
||||
}
|
||||
}
|
||||
|
||||
/// Use the starting position as a default value, corresponding to the
|
||||
/// "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" FEN string
|
||||
impl Default for ChessBoard {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
piece_occupancy: [
|
||||
// King
|
||||
Square::E1 | Square::E8,
|
||||
// Queen
|
||||
Square::D1 | Square::D8,
|
||||
// Rook
|
||||
Square::A1 | Square::A8 | Square::H1 | Square::H8,
|
||||
// Bishop
|
||||
Square::C1 | Square::C8 | Square::F1 | Square::F8,
|
||||
// Knight
|
||||
Square::B1 | Square::B8 | Square::G1 | Square::G8,
|
||||
// Pawn
|
||||
Rank::Second.into_bitboard() | Rank::Seventh.into_bitboard(),
|
||||
],
|
||||
color_occupancy: [
|
||||
Rank::First.into_bitboard() | Rank::Second.into_bitboard(),
|
||||
Rank::Seventh.into_bitboard() | Rank::Eighth.into_bitboard(),
|
||||
],
|
||||
combined_occupancy: Rank::First.into_bitboard()
|
||||
| Rank::Second.into_bitboard()
|
||||
| Rank::Seventh.into_bitboard()
|
||||
| Rank::Eighth.into_bitboard(),
|
||||
castle_rights: [CastleRights::BothSides; 2],
|
||||
en_passant: None,
|
||||
half_move_clock: 0,
|
||||
total_plies: 0,
|
||||
side: Color::White,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue