remove redundant methods for positions
This commit is contained in:
parent
263bb0ddb6
commit
bcd5a3182a
2 changed files with 39 additions and 72 deletions
|
|
@ -76,34 +76,6 @@ impl Position {
|
|||
})
|
||||
}
|
||||
|
||||
/// Tries to read a valid position from a text record.
|
||||
///
|
||||
/// This is a shortcut for parsing and validating a [`Setup`]:
|
||||
/// ```
|
||||
/// # use eschac::setup::Setup;
|
||||
/// # |s: &str| -> Option<eschac::position::Position> {
|
||||
/// Setup::from_text_record(s).ok().and_then(|pos| pos.into_position().ok())
|
||||
/// # };
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn from_text_record(s: &str) -> Option<Self> {
|
||||
Setup::from_text_record(s)
|
||||
.ok()
|
||||
.and_then(|pos| pos.into_position().ok())
|
||||
}
|
||||
|
||||
/// Returns the text record of the position.
|
||||
///
|
||||
/// This is a shortcut for:
|
||||
/// ```
|
||||
/// # |position: eschac::position::Position| {
|
||||
/// position.as_setup().to_text_record()
|
||||
/// # };
|
||||
#[inline]
|
||||
pub fn to_text_record(&self) -> String {
|
||||
self.as_setup().to_text_record()
|
||||
}
|
||||
|
||||
/// Returns all the legal moves on the position.
|
||||
#[inline]
|
||||
pub fn legal_moves<'l>(&'l self) -> Moves<'l> {
|
||||
|
|
@ -171,33 +143,6 @@ impl Position {
|
|||
self.0.en_passant = OptionSquare::None;
|
||||
}
|
||||
|
||||
/// Returns the occupancy of a square.
|
||||
#[inline]
|
||||
pub fn get(&self, square: Square) -> Option<Piece> {
|
||||
self.0.get(square)
|
||||
}
|
||||
|
||||
/// Returns the color whose turn it is to play.
|
||||
#[inline]
|
||||
pub fn turn(&self) -> Color {
|
||||
self.0.turn()
|
||||
}
|
||||
|
||||
/// Returns `true` if castling is available for the given color and side.
|
||||
#[inline]
|
||||
pub fn castling_rights(&self, color: Color, side: CastlingSide) -> bool {
|
||||
self.0.castling_rights(color, side)
|
||||
}
|
||||
|
||||
/// Returns the en passant target square if it exists.
|
||||
///
|
||||
/// Note that if an en passant target square exists, it does not mean that taking en passant is
|
||||
/// legal or even pseudo-legal.
|
||||
#[inline]
|
||||
pub fn en_passant_target_square(&self) -> Option<Square> {
|
||||
self.0.en_passant_target_square()
|
||||
}
|
||||
|
||||
/// Discards the castling rights for the given color and side.
|
||||
#[inline]
|
||||
pub fn remove_castling_rights(&mut self, color: Color, side: CastlingSide) {
|
||||
|
|
@ -420,14 +365,14 @@ impl Position {
|
|||
SanInner::Castle(CastlingSide::Short) => (
|
||||
Role::King,
|
||||
Role::King,
|
||||
Square::from_coords(File::E, self.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::G, self.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::E, self.0.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::G, self.0.turn().home_rank()).bitboard(),
|
||||
),
|
||||
SanInner::Castle(CastlingSide::Long) => (
|
||||
Role::King,
|
||||
Role::King,
|
||||
Square::from_coords(File::E, self.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::C, self.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::E, self.0.turn().home_rank()).bitboard(),
|
||||
Square::from_coords(File::C, self.0.turn().home_rank()).bitboard(),
|
||||
),
|
||||
SanInner::Normal {
|
||||
role,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue