Rules: 1) Roll the Dice. 2) If user rolled a 1: The pot gets set to zero The oth
ID: 3550432 • Letter: R
Question
Rules:
1) Roll the Dice.
2) If user rolled a 1:
The pot gets set to zero
The other player goes to step 1.
3) Else roll of 2-6 is added to the pot.
4) User can choose to hold or roll again.
Choice ROLL= Return to Step 1.
Choice HOLD=
-Increment Player score by the pot amount.
-Pot gets set to 0.
-second player gets to roll and goes to Step 1.
Explanation / Answer
from random import randint def one_round(total, strategy): round = 0 while True: value = randint(1,6) round = round + value if Value == 1: round = 0 break if round + total >= 63: break if strategy == 'Sum13': if round >= 13: break if strategy == 'Sum6': if round >= 6: break return round def one_game(strategy_a, strategy_b): total_a = 0 total_b = 0 while True: round_a = one_round(total_a, strategy_a) round_b = one_round(total_b, strategy_b) total_a += round_a total_b += round_b while total_a >= 63 or total_b >=63: break if total_a >= 63: return 'A' elif total_b >= 63: return 'B' elif total_a == total_b: return 'D' def play_games(n_games, strategy_a, strategy_b): n_games = 100 for i in range(n_games):
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.