[][src]Enum chess_engine::Move

pub enum Move {
    QueenSideCastle,
    KingSideCastle,
    Piece(PositionPosition),
    Resign,
}

A move that can be applied to a board. When applied to a board, the board assumes that the move is being applied for the current turn's player.

Variants

QueenSideCastle

If the current player is white, move the king to the C1 square, and the kingside rook to the D1 square. If the current player is black, however, move the king to the C8 square, and the kingside rook to the D8 square.

Castling can only be performed if

  1. The king has not moved at all since the game began
  2. The respective rook (kingside or queenside) has also not moved
  3. The square adjacent to the king on the respective side is not threatened by an enemy piece

If all of these conditions are satisfied, castling is a legal move

KingSideCastle

If the current player is white, move the king to the G1 square, and the kingside rook to the F1 square. If the current player is black, however, move the king to the G8 square, and the kingside rook to the F8 square.

Move a piece from one square to another. This can allow the player to capture another piece, by simply moving a piece to the position of an enemy piece.

Additionally, this can be used to en-passant capture, even though the en-passant square itself does not contain any capturable pieces.

En-passant captures MUST be performed with a pawn, upon an enemy pawn that has just surpassed it by move two squares. An en-passant capture must also be performed the turn immediately after the enemy pawn surpasses the allied pawn. After the one turn a player has to en-passant capture, the en-passant square is forgotten and can no longer be used.

Resign

When played by another player, it awards victory to the other.

Implementations

impl Move[src]

pub fn parse(repr: String) -> Result<Self, String>[src]

Try to parse a Move from a string.

Possible valid formats include:

  • "resign"
  • "resigns"
  • "castle queenside"
  • "O-O-O" (correct notation)
  • "o-o-o" (incorrect notation, but will accept)
  • "0-0-0" (incorrect notation, but will accept)
  • "castle kingside"
  • "O-O" (correct notation)
  • "o-o" (incorrect notation, but will accept)
  • "0-0" (incorrect notation, but will accept)
  • "e2e4"
  • "e2 e4"
  • "e2 to e4"

Parsing a move such as "knight to e4" or "Qxe4" will NOT work.

Trait Implementations

impl Clone for Move[src]

impl Copy for Move[src]

impl Debug for Move[src]

impl Display for Move[src]

impl Eq for Move[src]

impl Ord for Move[src]

impl PartialEq<Move> for Move[src]

impl PartialOrd<Move> for Move[src]

impl StructuralEq for Move[src]

impl StructuralPartialEq for Move[src]

impl TryFrom<String> for Move[src]

Try to parse a Move from a string.

Possible valid formats include:

  • "resign"
  • "resigns"
  • "castle queenside"
  • "O-O-O" (correct notation)
  • "o-o-o" (incorrect notation, but will accept)
  • "0-0-0" (incorrect notation, but will accept)
  • "castle kingside"
  • "O-O" (correct notation)
  • "o-o" (incorrect notation, but will accept)
  • "0-0" (incorrect notation, but will accept)
  • "e2e4"
  • "e2 e4"
  • "e2 to e4"

Parsing a move such as "knight to e4" or "Qxe4" will NOT work.

type Error = String

The type returned in the event of a conversion error.

Auto Trait Implementations

impl Send for Move[src]

impl Sync for Move[src]

impl Unpin for Move[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.