Esempio n. 1
0
def max_scoring_num_rolls(dice=six_sided, num_samples=1000):
    """Return the number of dice (1 to 10) that gives the highest average turn
    score by calling roll_dice with the provided DICE over NUM_SAMPLES times.
    Assume that dice always return positive outcomes.

    >>> dice = make_test_dice(3)
    >>> max_scoring_num_rolls(dice)
    10
    """
    # BEGIN Question 7
    highest = 0
    iVal = 0
    for i in range(10):

        val = roll_dice(i + 1, dice)
        if val > highest:
            highest = val
            iVal = i
    print(iVal + 1)
Esempio n. 2
0
 def test_roll_dice1(self):
     val = roll_dice(1, make_test_dice(4, 2, 1, 3))
     self.assertTrue(val == 4)
Esempio n. 3
0
 def test_roll_dice3(self):
     val = roll_dice(3, make_test_dice(4, 2, 1, 3))
     self.assertTrue(val == 1)
Esempio n. 4
0
 def test_roll_dice2(self):
     val = roll_dice(2, make_test_dice(4, 2, 1, 3))
     self.assertTrue(val == 6)