[−][src]Enum chess_engine::Piece
A piece on a board.
Every piece has both a color and a position. These, combined with the type of piece it is, determine things like
- The validity of legal moves
- The validity of legal attacks
- Move generation
- Material and positional value
Variants
Implementations
impl Piece[src]
pub fn get_name(&self) -> &'static str[src]
Get the name of the piece such as "pawn" or "king".
All names are lowercase.
pub fn get_material_value(&self) -> i32[src]
Get the material value for a piece. | Name | Value | |-|-| | King | 99999 | | Queen | 9 | | Rook | 5 | | Bishop | 3 | | Knight | 3 | | Pawn | 1 |
pub fn get_weighted_value(&self) -> f64[src]
Get the weighted value of a piece. This simply factors in position to the pieces value. For example, a knight that is in the center is more favorable than a knight on the side of the board. Similarly, a king in the center of the board is highly unfavorable compared to a king its respective side.
Additionally, the weighted value of the piece is 10 times greater than its material value, plus or minus a weight ranging between 5.0 and -5.0.
pub fn with_color(&self, color: Color) -> Self[src]
Get the color of a given piece.
pub fn get_color(&self) -> Color[src]
Get the color of a given piece.
pub fn get_pos(&self) -> Position[src]
Get the position of a piece.
pub fn is_king(&self) -> bool[src]
Is this piece a king?
pub fn is_queen(&self) -> bool[src]
Is this piece a queen?
pub fn is_rook(&self) -> bool[src]
Is this piece a rook?
pub fn is_bishop(&self) -> bool[src]
Is this piece a bishop?
pub fn is_knight(&self) -> bool[src]
Is this piece a knight?
pub fn is_pawn(&self) -> bool[src]
Is this piece a pawn?
pub fn is_starting_pawn(&self) -> bool[src]
Is this piece a starting pawn?
A starting pawn is a pawn that has not been pushed yet whatsoever.
pub fn is_queenside_rook(&self) -> bool[src]
Is this piece in the starting position for the queenside rook?
This method will only return true for rooks that are in the position of the queenside rook, not for any particular rook.
pub fn is_kingside_rook(&self) -> bool[src]
Is this piece in the starting position for the kingside rook?
This method will only return true for rooks that are in the position of the kingside rook, not for any particular rook.
pub fn move_to(&self, new_pos: Position) -> Self[src]
Change the position of this piece to a new position.
For example, Pawn(Color::White, E4).move_to(E5) will result in
Pawn(Color::White, E5). This does not check for move legality,
it merely creates a new piece with the same color and type, but
with a new position.
Trait Implementations
impl Clone for Piece[src]
fn clone(&self) -> Piece[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for Piece[src]
impl Debug for Piece[src]
impl Display for Piece[src]
impl Eq for Piece[src]
impl From<Piece> for Square[src]
impl Ord for Piece[src]
fn cmp(&self, other: &Piece) -> Ordering[src]
#[must_use]pub fn max(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self1.50.0[src]
impl PartialEq<Piece> for Piece[src]
impl PartialOrd<Piece> for Piece[src]
fn partial_cmp(&self, other: &Piece) -> Option<Ordering>[src]
fn lt(&self, other: &Piece) -> bool[src]
fn le(&self, other: &Piece) -> bool[src]
fn gt(&self, other: &Piece) -> bool[src]
fn ge(&self, other: &Piece) -> bool[src]
impl StructuralEq for Piece[src]
impl StructuralPartialEq for Piece[src]
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T> ToString for T where
T: Display + ?Sized, [src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,