Implement 'Default' for 'ChessBoard'
This commit is contained in:
parent
b5bb613b5e
commit
9cddda7478
|
@ -272,6 +272,42 @@ impl ChessBoard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Return a [ChessBoard] from the given FEN string.
|
/// Return a [ChessBoard] from the given FEN string.
|
||||||
impl FromFen for ChessBoard {
|
impl FromFen for ChessBoard {
|
||||||
type Err = Error;
|
type Err = Error;
|
||||||
|
|
Loading…
Reference in a new issue