pub struct UnMove {
pub from: Square,
pub to: Square,
/* private fields */
}Expand description
Information about a move.
Called UnMove not to be confused with shakmaty::Move. When there is no doubt about which one is reffered to, can be called “move”.
Fields§
§from: Square§to: SquareImplementations§
Source§impl UnMove
impl UnMove
Sourcepub fn from_retro_uci(retro_uci: &str) -> Result<UnMove, ParseRetroUciError>
pub fn from_retro_uci(retro_uci: &str) -> Result<UnMove, ParseRetroUciError>
movements are represented with uci, but for uncapture and unpromote a special syntax is used:
-Uncapture: the piece left at the source square is indicated at the beginning, follow by normal uci move. e.g: “Re2e4” the piece on e2 goes on e4 and leaves a Rook from the opposite color on e2.
-Unpromotion: “U” and after the square from which the piece will underpromote and the
source square must be on the 8th or 1st rank, and dest square must be on first or second rank.
e.g: “Ue8e7”.
An unpromotion can also be an uncapture, in this case it’s noted “
-En passant: “E” then the source square of the pawn and the destination of it.
When a move is en-passsant, it cannot Uncapture anything (since the pawn uncapture is already implied)
e.g “Ed6e5”. Note than it’s different than “Pd6e5”. In the first example, the uncaptured pawn is in d5,
while in the second one it’s in d6.
regex: r“[UE]?[NBRQ]?([abcdefgh][1-8]){2}“
Note: A unmove being accepted does not means it is for sure legal, just syntaxically correct
§Examples
use retroboard::UnMove;
use shakmaty::{Square, Role};
let simple_move: UnMove = UnMove::from_retro_uci("Pe2e4").unwrap();
assert_eq!(simple_move.from, Square::E2);
assert_eq!(simple_move.to, Square::E4);
assert_eq!(simple_move.uncapture(), Some(Role::Pawn));
let unpromotion: UnMove = UnMove::from_retro_uci("Ue8e7").unwrap();
assert_eq!(unpromotion.from, Square::E8);
assert_eq!(unpromotion.to, Square::E7);
assert!(unpromotion.is_unpromotion());
assert!(!unpromotion.is_en_passant());
let en_passant: UnMove = UnMove::from_retro_uci("Ee3d4").unwrap();
assert_eq!(en_passant.from, Square::E3);
assert_eq!(en_passant.to, Square::D4);
assert!(en_passant.is_en_passant());
assert!(!en_passant.is_unpromotion());Sourcepub fn to_retro_uci(&self) -> String
pub fn to_retro_uci(&self) -> String
Returns a string following the retro uci standard. See UnMove::from_retro_uci for more information.
pub fn is_uncapture(&self) -> bool
pub fn uncapture(&self) -> Option<Role>
pub fn is_unpromotion(&self) -> bool
pub fn is_en_passant(&self) -> bool
Sourcepub fn uncapture_square(&self) -> Option<Square>
pub fn uncapture_square(&self) -> Option<Square>
If the move is an uncapture moves, returns the square when the piece uncaptured will land.
It is always the from square, except for en-passant move.
§Examples
use retroboard::UnMove;
use shakmaty::Square;
assert_eq!(
UnMove::from_retro_uci("Ed3e4")
.unwrap()
.uncapture_square()
.unwrap(),
Square::D4,
);
assert_eq!(
UnMove::from_retro_uci("Qa8h1")
.unwrap()
.uncapture_square()
.unwrap(),
Square::A8,
);