Skip to content

Commit

Permalink
fixed win
Browse files Browse the repository at this point in the history
  • Loading branch information
bananasmoothii committed Oct 12, 2023
1 parent 7bbe29d commit 5e29964
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/game/connect4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ impl Game for ConnectFour {
* Scores are invalid if the line cannot be completed
*/
fn get_score(&self, player: Self::Player) -> Self::Score {
if let Some(winner) = self.winner {
return if winner == player {
Self::Score::MAX
} else {
Self::Score::MIN
}
}
let p1_score = self.calculate_score(self.p1_aligns2, self.p1_aligns3)
- self.calculate_score(self.p2_aligns2, self.p2_aligns3);
if player.get() == 1u8 {
Expand Down

0 comments on commit 5e29964

Please sign in to comment.