diff --git a/dice_stats.py b/dice_stats.py index af915f4..b8c5c1d 100644 --- a/dice_stats.py +++ b/dice_stats.py @@ -65,24 +65,24 @@ for trial in tqdm(range(trials)): print(f"All Ones: {successes/trials}") dice = FiveDice() -successes = 0 -trials = 1000000 -for trial in tqdm(range(trials)): +successes_3 = 0 +trials_3 = 1000000 +for trial in tqdm(range(trials_3)): dice.roll() if dice.is_three_of_a_kind(): - successes += 1 + successes_3 += 1 -print(f"Three of a Kind: {successes/trials}") +print(f"Three of a Kind: {successes_3/trials_3}") dice = FiveDice() -successes = 0 -trials = 1000000 -for trial in tqdm(range(trials)): +successes_4 = 0 +trials_4 = 1000000 +for trial in tqdm(range(trials_4)): dice.roll() if dice.is_four_of_a_kind(): - successes += 1 + successes_4 += 1 -print(f"Four of a Kind: {successes/trials}") +print(f"Four of a Kind: {successes_4/trials_4}") diff --git a/play.py b/play.py index 773f7f3..1e9becd 100644 --- a/play.py +++ b/play.py @@ -3,12 +3,18 @@ from yahtzee_goals import ( GoalOnes, GoalTwos, GoalThrees, + GoalFours, + GoalFives, + GoalSixes ) goals = [ GoalOnes(), GoalTwos(), GoalThrees(), + GoalFours(), + GoalFives(), + GoalSixes() ] game = Yahtzee(goals) diff --git a/yahtzee_goals.py b/yahtzee_goals.py index 10af574..44d6bfa 100644 --- a/yahtzee_goals.py +++ b/yahtzee_goals.py @@ -40,3 +40,45 @@ class GoalThrees: if die.face == 3: total += 3 return total + +class GoalFours: + "Four points for each four" + + def prompt(self, dice): + potential_score = self.score(dice) + return f"Fours ({potential_score})" + + def score(self, dice): + total = 0 + for die in dice: + if die.face == 4: + total += 4 + return total + +class GoalFives: + "five points for each five" + + def prompt(self, dice): + potential_score = self.score(dice) + return f"Fives ({potential_score})" + + def score(self, dice): + total = 0 + for die in dice: + if die.face == 5: + total += 5 + return total + +class GoalSixes: + "six points for each Six" + + def prompt(self, dice): + potential_score = self.score(dice) + return f"Sixes ({potential_score})" + + def score(self, dice): + total = 0 + for die in dice: + if die.face == 6: + total += 6 + return total