Closed UlisseMini closed 4 years ago
I "solved" my problem by writing this
use vampirc_uci as uci;
pub fn to_chess_square(uci_square: uci::UciSquare) -> chess::Square {
chess::Square::make_square(
chess::Rank::from_index(uci_square.rank as usize - 1),
chess::File::from_index(uci_square.file as usize - 'a' as usize),
)
}
pub fn to_chess_piece(uci_piece: uci::UciPiece) -> chess::Piece {
use chess::Piece;
use vampirc_uci::UciPiece::*;
match uci_piece {
King => Piece::King,
Queen => Piece::Queen,
Knight => Piece::Knight,
Pawn => Piece::Pawn,
Bishop => Piece::Bishop,
Rook => Piece::Rook,
}
}
pub fn to_chess_move(uci_move: uci::UciMove) -> chess::ChessMove {
let from = to_chess_square(uci_move.from);
let to = to_chess_square(uci_move.to);
let mut promo = None;
if uci_move.promotion.is_some() {
promo = Some(to_chess_piece(uci_move.promotion.unwrap()));
}
chess::ChessMove::new(from, to, promo)
}
but that is hardly a solution
Yeah, vampirc has its own move generation and representation of chess concepts (currently not public), but in theory it would be easy to do this as an optional dependency.
Implemented in #11, to be released as 0.9.0.
Released in 0.9.0.
It would be nice to support native integration into the
chess
crate, I understand you may not want to depend on it simply for a nicer API for the people who happen to be using it, but I think (i'm a beginner) it should be possible to hide such an API behind some sort of compile time checks.Just my 2 cents, likely i'm totally wrong.