added method uci_notation to struct BitMove
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
use super::utils::*;
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct BitMove {
|
pub struct BitMove {
|
||||||
@@ -54,6 +55,17 @@ impl BitMove {
|
|||||||
pub fn promotion_piece(&self) -> Option<u8> {
|
pub fn promotion_piece(&self) -> Option<u8> {
|
||||||
return self.promotion_piece;
|
return self.promotion_piece;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn uci_notation(&self) -> String {
|
||||||
|
let mut notation = notation_from_square_number(self.from_square());
|
||||||
|
notation.push_str(¬ation_from_square_number(self.to_square()));
|
||||||
|
|
||||||
|
if let Some(promotion_piece) = self.promotion_piece {
|
||||||
|
notation.push(get_character_by_piece_id(promotion_piece).to_ascii_lowercase());
|
||||||
|
}
|
||||||
|
|
||||||
|
return notation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq)]
|
#[derive(Copy, Clone, PartialEq, Eq)]
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ pub fn try_get_square_number_from_notation(notation: &str) -> Result<u8, ()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const PIECE_CHARACTERS: [char; 12] = ['P', 'N', 'B', 'R', 'Q', 'K', 'p', 'n', 'b', 'r', 'q', 'k'];
|
||||||
|
pub fn get_character_by_piece_id(id: u8) -> char {
|
||||||
|
return PIECE_CHARACTERS[id as usize];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// <----- TESTS ----->
|
// <----- TESTS ----->
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user