I added the goals of fours, fives, sixes and a

full house. Then I imported them to play.py so they would be integrated into the game.

OOP felt more comfortable than the data science problems, but was more challenging than the drawing projects
since the feedback again is not visual. However, this feels like a middle ground between the two. I think that the
use of something familiar, like Yahtzee was a huge help in this proess. I can conceptialize the adjustments I am
making becasue I have done them before. Additionally, it felt like the steps for the game itself were very confusing,
but the goals were managable. I understood how to piece together the goals and make the applicable. Looking ahead,
I am anticipating the challenge of building out a game of my own. This is going to be a challenge! The part of OOP
that I related to was the confines given (a game, a die, a goal) then the challenge being operating within them to accomplish tasks.
Creating from sratch is tough! ... but not in a bad way. I will just ahve to establish my own confines/rules, then develop.
It is a challenge to create from scratch when I have not mastered the rules yet. I look forward to continuing to develop this skill!

If yahtzee was written in Unit 1, I would invision it to be well, a visual. The die itself would roll and that would act as the "roll."
That being said, the goals and steps of winning the game seem like they are a little out of reach of Unit 1. It would be the rolling of the
dice and that's it.

If this was in Unit 2, the game may have been converted into a data set. The instances may have already been run and
documented in a spreadsheet that was uploaded. Then that data would have been analyzed and plotted as data, rather than as a game. the goals could
have been evaluated as statisical instacnes to be analyzed rather than turns to be played.
This commit is contained in:
Rebecca Hankey 2024-11-21 21:16:19 -05:00
parent 0ffe049e3d
commit 7bfef15ec7
2 changed files with 73 additions and 0 deletions

View File

@ -3,12 +3,20 @@ from yahtzee_goals import (
GoalOnes,
GoalTwos,
GoalThrees,
GoalFours,
GoalFives,
GoalSixes,
GoalFullHouse,
)
goals = [
GoalOnes(),
GoalTwos(),
GoalThrees(),
GoalFours(),
GoalFives(),
GoalSixes(),
GoalFullHouse(),
]
game = Yachtzee(goals)

View File

@ -43,3 +43,68 @@ class GoalThrees:
if die.face == 3:
total += 3
return total
class GoalFours:
"Four points for each four"
used = False
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"
used = False
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"
used = False
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
class GoalFullHouse:
"25 points for a full house. one pair and three of a kind"
used = False
def prompt(self, dice):
potential_score = self.score(dice)
return f"Full House ({potential_score})"
def score(self, dice):
counts = []
for face in range(1, 7):
count = dice.count(face)
if count > 0:
counts.append(count)
if sorted(counts) == [2, 3]:
return 25
return 0