Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bot promotion using UCI standard #97

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/board.rs
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,26 @@ impl Board {
let to_y = get_int_from_char(converted_move.chars().nth(2));
let to_x = get_int_from_char(converted_move.chars().nth(3));

let mut promotion_piece: Option<PieceType> = None;
if movement.chars().count() == 5 {
promotion_piece = match movement.chars().nth(4) {
Some('q') => Some(PieceType::Queen),
Some('r') => Some(PieceType::Rook),
Some('b') => Some(PieceType::Bishop),
Some('n') => Some(PieceType::Knight),
_ => None,
};
}

self.move_piece_on_the_board(
&Coord::new(from_y as u8, from_x as u8),
&Coord::new(to_y as u8, to_x as u8),
);

if promotion_piece.is_some() {
self.board[to_y as usize][to_x as usize] =
Some((promotion_piece.unwrap(), self.player_turn));
}
if self.is_bot_starting {
self.flip_the_board();
}
Expand Down
Loading