pub enum Move {
QueenSideCastle,
KingSideCastle,
Piece(Position, Position),
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
- The king has not moved at all since the game began
- The respective rook (kingside or queenside) has also not moved
- 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.
Piece(Position, Position)
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§
Source§impl Move
impl Move
Sourcepub fn parse(repr: String) -> Result<Self, String>
pub fn parse(repr: String) -> Result<Self, String>
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§
Source§impl Ord for Move
impl Ord for Move
Source§impl PartialOrd for Move
impl PartialOrd for Move
Source§impl TryFrom<String> for Move
Try to parse a Move from a string.
impl TryFrom<String> for Move
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.