Struct inanis::state::movescan::Move

source ·
pub struct Move {
    pub data: u16,
}

Fields§

§data: u16

Implementations§

source§

impl Move

source

pub fn new(from: usize, to: usize, flags: u8) -> Self

Constructs a new instance of Move with stored from, to and flags.

source

pub const fn new_from_raw(data: u16) -> Self

Constructs a new instance of Move using raw bits, which will be directly used as a data.

source

pub fn new_random() -> Self

Constructs a new instance of Move with random values, not restricted by chess rules.

source

pub fn get_from(&self) -> usize

Gets source square from the internal data.

source

pub fn get_to(&self) -> usize

Gets destination square from the internal data.

source

pub fn get_flags(&self) -> u8

Gets flags from the internal data.

source

pub fn get_promotion_piece(&self) -> usize

Gets promotion piece based on the flags saved in the internal data.

source

pub fn is_some(&self) -> bool

Checks if there is any data present or it’s just a default move.

source

pub fn is_empty(&self) -> bool

Checks if there is any data present or it’s just a default move.

source

pub fn is_single_push(&self) -> bool

Checks if the move is a single push.

source

pub fn is_double_push(&self) -> bool

Checks if the move is a double push.

source

pub fn is_quiet(&self) -> bool

Checks if the move is quiet (single or double pushes).

source

pub fn is_capture(&self) -> bool

Checks if the move is a capture (excluding en passant, but including promotions).

source

pub fn is_en_passant(&self) -> bool

Checks if the move is en passant.

source

pub fn is_promotion(&self) -> bool

Checks if the move is a promotion (including captures).

source

pub fn is_castling(&self) -> bool

Checks if the move is a short or long castling.

Checks if the move is legal, using board as the context.

source§

impl Move

source

pub fn from_short_notation( text: &str, board: &mut Board ) -> Result<Move, String>

Converts short-notated move (e4, Rc8, Qxb6) in text into the Move instance, using the board as context. Returns Err with the proper message if text couldn’t be parsed correctly.

source

pub fn from_long_notation(text: &str, board: &Board) -> Result<Move, String>

Converts long-notated move (e2e4, a1a8) in text into the Move instance, using the board as context. Returns Err with the proper message if text couldn’t be parsed correctly.

source

pub fn to_long_notation(self) -> String

Converts move into the long notation (e2e4, a1a8).

Trait Implementations§

source§

impl Clone for Move

source§

fn clone(&self) -> Move

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Default for Move

source§

fn default() -> Self

Constructs a new instance of Move with zeroed values.

source§

impl Display for Move

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Move

source§

fn eq(&self, other: &Move) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Move

source§

impl Eq for Move

source§

impl StructuralPartialEq for Move

Auto Trait Implementations§

§

impl RefUnwindSafe for Move

§

impl Send for Move

§

impl Sync for Move

§

impl Unpin for Move

§

impl UnwindSafe for Move

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.