diff --git a/rdraught/examples/checkers.rs b/rdraught/examples/checkers.rs index 05937a1..7f58c20 100644 --- a/rdraught/examples/checkers.rs +++ b/rdraught/examples/checkers.rs @@ -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)]); diff --git a/rdraught/src/draughts.rs b/rdraught/src/draughts.rs index 94c1455..1258c0f 100644 --- a/rdraught/src/draughts.rs +++ b/rdraught/src/draughts.rs @@ -492,6 +492,17 @@ impl DraughtsGame { }; (best_move, analyzed_moves) } + + pub fn winner(&self) -> Option { + 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 {