[−][src]Struct chess_engine::Position
Implementations
impl Position[src]
pub const fn king_pos(color: Color) -> Self[src]
Return the starting position for a given color's king.
pub const fn queen_pos(color: Color) -> Self[src]
Return the starting position for a given color's queen.
pub const fn new(row: i32, col: i32) -> Self[src]
Create a Position from its respective row or column number.
The row and column numbers can be any of 0, 1, 2, 3, 4, 5, 6, or 7.
Examples:
A1 = Position::new(0, 0)A8 = Position::new(7, 0)H1 = Position::new(0, 7)H8 = Position::new(7, 7)
pub fn pgn(s: &str) -> Result<Self, String>[src]
Parse a position from PGN. This simply just supports positions like
e4 and D8.
pub fn is_on_board(&self) -> bool[src]
Is this position a valid spot on the board?
pub fn is_off_board(&self) -> bool[src]
Is this position NOT a valid spot on the board?
pub fn get_row(&self) -> i32[src]
Get the row number of the position. This can be any of 0, 1, 2, 3, 4, 5, 6, or 7.
pub fn get_col(&self) -> i32[src]
pub fn is_diagonal_to(&self, other: Self) -> bool[src]
Is this position diagonal to another position?
pub fn is_orthogonal_to(&self, other: Self) -> bool[src]
Is this position orthogonal to another position?
pub fn is_adjacent_to(&self, other: Self) -> bool[src]
Is this position adjacent to another position?
Adjacent positions have either:
- A diagonal distance of one from each other
- An orthogonal distance of one from each other
pub fn is_below(&self, other: Self) -> bool[src]
Is this position beneath another position on the board? Pieces "beneath" other pieces on the board have lower ranks.
So, for example, A7 is below A8.
pub fn is_above(&self, other: Self) -> bool[src]
Is this position above another position on the board? Pieces "above" other pieces on the board have higher ranks.
So, for example, A8 is above A8.
pub fn is_left_of(&self, other: Self) -> bool[src]
Is this position left of another position on the board? Pieces "left of" other pieces on the board have a lower lexigraphical column character.
So, for example, A8 is left of B8.
pub fn is_right_of(&self, other: Self) -> bool[src]
Is this position right of another position on the board? Pieces "right of" other pieces on the board have a higher lexigraphical column character.
So, for example, B8 is right of A8.
pub fn next_below(&self) -> Self[src]
Get the position directly below this position.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn next_above(&self) -> Self[src]
Get the position directly above this position.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn pawn_up(&self, ally_color: Color) -> Self[src]
Get the next square upwards from a respective player's pawn.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn pawn_back(&self, ally_color: Color) -> Self[src]
Get the next square backwards from a respective player's pawn.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn next_left(&self) -> Self[src]
Get the position directly left of this position.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn next_right(&self) -> Self[src]
Get the position directly right of this position.
IMPORTANT NOTE: This will NOT check for positions
off of the board! You could easily get an invalid
position if you do not check with the is_on_board
method!
pub fn is_starting_pawn(&self, color: Color) -> bool[src]
Is this pawn on the starting rank for the respective player?
pub fn is_kingside_rook(&self) -> bool[src]
Is this the starting position of the kingside rook?
pub fn is_queenside_rook(&self) -> bool[src]
Is this the starting position of the queenside rook?
pub fn diagonals_to(&self, to: Self) -> Vec<Self>[src]
Get the list of positions from this position to another position, moving diagonally.
This does not include the from position, and includes the to position.
pub fn orthogonals_to(&self, to: Self) -> Vec<Self>[src]
Get the list of positions from this position to another position, moving orthogonally.
This does not include the from position, and includes the to position.
pub fn is_knight_move(&self, other: Self) -> bool[src]
Trait Implementations
impl Clone for Position[src]
fn clone(&self) -> Position[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl Copy for Position[src]
impl Debug for Position[src]
impl Display for Position[src]
impl Eq for Position[src]
impl Ord for Position[src]
fn cmp(&self, other: &Position) -> 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<Position> for Position[src]
impl PartialOrd<Position> for Position[src]
fn partial_cmp(&self, other: &Position) -> Option<Ordering>[src]
fn lt(&self, other: &Position) -> bool[src]
fn le(&self, other: &Position) -> bool[src]
fn gt(&self, other: &Position) -> bool[src]
fn ge(&self, other: &Position) -> bool[src]
impl StructuralEq for Position[src]
impl StructuralPartialEq for Position[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>,