I'm designing a function that calls a function of the randomly rolled die. If both numbers are guessed correctly, money is tripled. If non are, money is lost. If one is, the sum of die rolled is the losing target. If you roll the losing target before rolling either guess1 or guess2, you lose, if not, you win and double your money...
I am struggling to make it so that the order of die rolled doesn't matter and it doesn't double count numbers.
I am also struggling to make a while loop for the losing target situation... please help! Very new to this.
def play(guess1:int,guess2:int, dollars:int):
random_die1 = roll_one_die() ##calling helper function
random_die2 = roll_one_die()
win_count = 0 ## these are not correct, not sure how to properly account for different rolls
if guess1 == random_die1:
win_count = 1
else:
win_count = 0
if guess1 == random_die2:
if win_count==1:
win_count = 1
else:
win_count = 1
if guess2 == random_die1:
if guess1 != random_die1 and guess1 != random_die2:
win_count+= 1
else:
win_count += 0
if guess2 == random_die2:
if guess2 != random_die1 and guess2 != random_die2:
win_count+= 1
#if win_count==2:
#win_count=2
else:
win_count +=0
if win_count ==2:
dollars=dollars*3
elif win_count ==0:
dollars=0
else:
losing_target= random_die1+random_die2
new_roll1 = roll_one_die()
new_roll2 = roll_one_die()
sum_of = (new_roll1 + new_roll2)
if losing_target==sum_of:
dollars==0
while sum_of!= losing_target: ## not sure how to properly loop so first situation = win or loss
sum_of == new_roll1 + new_roll2
if new_roll1 == guess1 or new_roll1 == guess2 or new_roll2 == guess1 or new_roll2 == guess2:
dollars=dollars*2
return(dollars)
Aucun commentaire:
Enregistrer un commentaire