diff --git a/tron/game.py b/tron/game.py index 27c65db..156aaa9 100644 --- a/tron/game.py +++ b/tron/game.py @@ -187,14 +187,21 @@ class Game: self.next_frame(window) - for (index, pp) in enumerate(self.pps): + for pp in self.pps: if pp.alive: alive_count += 1 - alive = index + alive = pp.id if alive_count <= 1: if alive_count == 1: - self.winner = alive + 1 + # If player one and two share the same position, it will + # mean that they reached the same tile at the same + # moment, so it's really a draw. + if self.pps[0].position[0] != self.pps[1].position[0] or \ + self.pps[0].position[1] != self.pps[1].position[1]: + + # Otherwise, the winner is the player that is still alive. + self.winner = alive break if window: