[board] Clean up a handful of things in position.rs
- Remove unused std::fmt::Write import - Refer to the piece! macro with $crate (I didn't know this was legal??) - Remove the doc comments on Position::flags - Remove {set,clear}_player_has_right_to_castle_flag - Remove an extraneous local variable from Position::place_piece()
This commit is contained in:
parent
ac5d8cc9d5
commit
71e93925b9
1 changed files with 3 additions and 21 deletions
|
@ -9,7 +9,6 @@ use crate::{
|
|||
};
|
||||
use std::cell::OnceCell;
|
||||
use std::fmt;
|
||||
use std::fmt::Write;
|
||||
|
||||
/// A lateral side of the board relative to the player. Kingside is the side the
|
||||
/// player's king starts on. Queenside is the side of the board the player's
|
||||
|
@ -23,7 +22,7 @@ pub(crate) enum BoardSide {
|
|||
macro_rules! position {
|
||||
[$($color:ident $shape:ident on $square:ident,)*] => {
|
||||
$crate::Position::from_iter([
|
||||
$(piece!($color $shape on $square)),*
|
||||
$($crate::piece!($color $shape on $square)),*
|
||||
].into_iter())
|
||||
};
|
||||
}
|
||||
|
@ -31,14 +30,6 @@ macro_rules! position {
|
|||
#[derive(Clone, Eq, PartialEq)]
|
||||
pub struct Position {
|
||||
color_to_move: Color,
|
||||
|
||||
/// Position flags indicating various bits of game state. The flags are as
|
||||
/// follows:
|
||||
///
|
||||
/// 0. white can castle king-side
|
||||
/// 1. white can castle queen-side
|
||||
/// 2. black can castle king-side
|
||||
/// 3. black can castle queen-side
|
||||
flags: Flags,
|
||||
|
||||
/// Composite bitboards for all the pieces of a particular color.
|
||||
|
@ -131,15 +122,6 @@ impl Position {
|
|||
self.flags.player_has_right_to_castle(color, side)
|
||||
}
|
||||
|
||||
fn set_player_has_right_to_castle_flag(&mut self, color: Color, side: BoardSide) {
|
||||
self.flags.set_player_has_right_to_castle_flag(color, side);
|
||||
}
|
||||
|
||||
fn clear_player_has_right_to_castle_flag(&mut self, color: Color, side: BoardSide) {
|
||||
self.flags
|
||||
.clear_player_has_right_to_castle_flag(color, side);
|
||||
}
|
||||
|
||||
pub fn place_piece(&mut self, piece: Piece, square: Square) -> Result<(), PiecePlacementError> {
|
||||
let type_bb = self.bitboard_for_piece_mut(piece);
|
||||
|
||||
|
@ -149,8 +131,8 @@ impl Position {
|
|||
|
||||
type_bb.set_square(square);
|
||||
|
||||
let color_bb = &mut self.bitboard_for_color_mut(piece.color());
|
||||
color_bb.set_square(square);
|
||||
self.bitboard_for_color_mut(piece.color())
|
||||
.set_square(square);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue