added winner() method
This commit is contained in:
@@ -15,7 +15,7 @@ fn main() {
|
||||
pieces.push(Piece::CrownedRedPawn).unwrap();
|
||||
|
||||
board
|
||||
.pieces(&pieces)
|
||||
.pieces(pieces)
|
||||
.for_each(|pos| println!("({}, {}): {:?}", pos.row(), pos.col(), board[pos]));
|
||||
// println!("{:?}", board[Position::new(0, 0)]);
|
||||
|
||||
|
@@ -492,6 +492,17 @@ impl DraughtsGame {
|
||||
};
|
||||
(best_move, analyzed_moves)
|
||||
}
|
||||
|
||||
pub fn winner(&self) -> Option<Player> {
|
||||
if self.available_moves().next().is_none() {
|
||||
Some(match self.next_move {
|
||||
Player::White => Player::Red,
|
||||
Player::Red => Player::White,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
struct MoveHeapEntry {
|
||||
|
Reference in New Issue
Block a user