From 6ade1c83c7110c50329246c6efdc225f39b5e155 Mon Sep 17 00:00:00 2001 From: mdecker6 Date: Thu, 30 Oct 2025 12:55:05 -0400 Subject: [PATCH] I changed some code such as rolls and other things.. --- dice_stats.py | 4 ++-- die.py | 1 + yahtzee.py | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dice_stats.py b/dice_stats.py index 83a99cb..2af3450 100644 --- a/dice_stats.py +++ b/dice_stats.py @@ -20,8 +20,8 @@ class FiveDice: return True dice = FiveDice() -successes = 0 -trials = 1000000 +successes = 3 +trials = 10 for trial in tqdm(range(trials)): dice.roll() if dice.all_ones(): diff --git a/die.py b/die.py index 14580bb..00ee769 100644 --- a/die.py +++ b/die.py @@ -15,3 +15,4 @@ class Die: def roll(self): self.face = randint(1, 6) return self.face + diff --git a/yahtzee.py b/yahtzee.py index 69b0e97..9c542c9 100644 --- a/yahtzee.py +++ b/yahtzee.py @@ -109,3 +109,14 @@ class Yahtzee: if die.face in choice_ints: choice_ints.remove(die.face) return len(choice_ints) == 0 + +def play(self): + """Play an entire game. + Starts by greeting the user, then plays rounds until all the goals + have been used. When the game is over, tells the player their final + score. + """ + print("Welcome to Yahtzee!") + while self.count_unused_goals() > 0: + self.play_round() + print(f"Your final score was {self.score}") \ No newline at end of file