Enum chess_engine::Move[][src]

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

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.

Tuple Fields of Piece

0: Position1: Position
Resign

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

Implementations

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.