From 5e2996477f7dead01edcc7121db148f403fe96b9 Mon Sep 17 00:00:00 2001 From: Bananasmoothii <45853225+bananasmoothii@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:22:30 +0200 Subject: [PATCH] fixed win --- src/game/connect4.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/game/connect4.rs b/src/game/connect4.rs index 16a8766..9593650 100644 --- a/src/game/connect4.rs +++ b/src/game/connect4.rs @@ -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 {