fix othello player skip logic

This commit is contained in:
2025-02-10 10:23:28 -05:00
parent 3d3eb01143
commit 0bd8dec65d
5 changed files with 18 additions and 7 deletions

View File

@@ -196,7 +196,10 @@ impl Board {
}
pub fn game_winner(&self, turn: Piece) -> Option<Piece> {
if self.possible_moves(turn).count() > 0 {
// Wikipedia: `Players take alternate turns. If one player cannot make a valid move, play passes back to the other player. The game ends when the grid has filled up or if neither player can make a valid move.`
if self.possible_moves(turn).next().is_some() || self.possible_moves(!turn).next().is_some()
{
// player can still make a move, there is no winner
return None;
}