generated from mwc/lab_dice
I changed some code such as rolls and other things..
This commit is contained in:
@@ -20,8 +20,8 @@ class FiveDice:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
dice = FiveDice()
|
dice = FiveDice()
|
||||||
successes = 0
|
successes = 3
|
||||||
trials = 1000000
|
trials = 10
|
||||||
for trial in tqdm(range(trials)):
|
for trial in tqdm(range(trials)):
|
||||||
dice.roll()
|
dice.roll()
|
||||||
if dice.all_ones():
|
if dice.all_ones():
|
||||||
|
|||||||
1
die.py
1
die.py
@@ -15,3 +15,4 @@ class Die:
|
|||||||
def roll(self):
|
def roll(self):
|
||||||
self.face = randint(1, 6)
|
self.face = randint(1, 6)
|
||||||
return self.face
|
return self.face
|
||||||
|
|
||||||
|
|||||||
11
yahtzee.py
11
yahtzee.py
@@ -109,3 +109,14 @@ class Yahtzee:
|
|||||||
if die.face in choice_ints:
|
if die.face in choice_ints:
|
||||||
choice_ints.remove(die.face)
|
choice_ints.remove(die.face)
|
||||||
return len(choice_ints) == 0
|
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}")
|
||||||
Reference in New Issue
Block a user