Board::game_winner: remove unneeded argument

This commit is contained in:
Simon Gardling 2025-02-19 13:40:05 -05:00
parent 1061292409
commit 6f51c31752
Signed by: titaniumtown
GPG Key ID: 9AB28AC10ECE533D
3 changed files with 6 additions and 5 deletions

View File

@ -324,10 +324,11 @@ impl Board {
}
/// Returns the winner of the board (if any)
pub fn game_winner(&self, turn: Piece) -> Winner {
pub fn game_winner(&self) -> Winner {
// 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()
if self.possible_moves(Piece::Black).next().is_some()
|| self.possible_moves(Piece::White).next().is_some()
{
// player can still make a move, there is no winner
return Winner::None;

View File

@ -170,7 +170,7 @@ impl FutureMoves {
i,
j,
board: new_board,
winner: new_board.game_winner(new_color),
winner: new_board.game_winner(),
parent: Some(parent_idx),
children: Vec::new(),
value: 0,
@ -295,7 +295,7 @@ impl FutureMoves {
i: 0,
j: 0,
board,
winner: Winner::None,
winner: board.game_winner(),
parent: None,
children: Vec::new(),
value: 0,

View File

@ -97,7 +97,7 @@ impl Game {
println!("{}", self);
match self.board.game_winner(self.players[current_player].color()) {
match self.board.game_winner() {
Winner::Player(piece) => {
println!("{} Wins!", piece.text());
break;