added winner() method
This commit is contained in:
@@ -15,7 +15,7 @@ fn main() {
|
|||||||
pieces.push(Piece::CrownedRedPawn).unwrap();
|
pieces.push(Piece::CrownedRedPawn).unwrap();
|
||||||
|
|
||||||
board
|
board
|
||||||
.pieces(&pieces)
|
.pieces(pieces)
|
||||||
.for_each(|pos| println!("({}, {}): {:?}", pos.row(), pos.col(), board[pos]));
|
.for_each(|pos| println!("({}, {}): {:?}", pos.row(), pos.col(), board[pos]));
|
||||||
// println!("{:?}", board[Position::new(0, 0)]);
|
// println!("{:?}", board[Position::new(0, 0)]);
|
||||||
|
|
||||||
|
@@ -492,6 +492,17 @@ impl DraughtsGame {
|
|||||||
};
|
};
|
||||||
(best_move, analyzed_moves)
|
(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)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
struct MoveHeapEntry {
|
struct MoveHeapEntry {
|
||||||
|
Reference in New Issue
Block a user