Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The Rules for each players flip. 1. Flip the 3 coins. a. If there are no heads (

ID: 3748672 • Letter: T

Question

The Rules for each players flip.

1. Flip the 3 coins.

a. If there are no heads ( all tails ),

i. The pot gets set to zero

ii. The other player goes to step 1.

b. The number of heads is added to the pot.

2. User can choose to hold or flip again.

a. Choice FLIP. Return to Step 1.

b. Choice HOLD.

i. Increment Player score by the pot amount.

ii. Pot gets set to 0.

iii. second player gets to flip and goes to Step 1. Program Requirements :

Before each opponent begins flipping..

Output the score for the person and the computer.

Output the opponents whose turn is beginning and ask the user to hit enter to continue.

With each flip of the coins.

Output the result, and amount of the round pot.

If it’s the users flip ask if they want to Flip again ( F ) or Hold ( H ).

Your program should allow r, R, h or H as valid input.

The AI will continue playing until the round pot is 8 or more.

Once a players pot is greater or equal to 20 then they have won, it will no longer ask if they want to keep playing.

Once there is a winner

Score totals are output along with who the winner was. User or Computer

Player is asked if they want to play again Y or N. Valid input should be y, Y, yes, YES, or n, N, no, NO.

When a new game starts the starting flip goes to the player that did not flip last. If the User flipped last in the previous game, then the computer flips first and vice versa

This is what i have so far:

import random

human= 0

AI = 0

print('WELCOME TO GREEDY DICE')

def Human ():

global human

option= "f"

input("Your turn. Hit enter to continue.")

while (option == 'f' or option == 'F'):

pot = 0

coin= random.randint(0,2)

print("COINS : ",end= "")

if (coin == 1):

print("TTH ",end="")

elif (coin == 2):

print ("THH ",end="")

elif (coin == 3):

print("HHH ",end="")

else: print("TTT ",end="")

pot = pot + coin

human = human + coin

print("Pot : ",pot, end="")

if (human >=20):

print("Winner!")

print("SCORE: You: ",human," AI: ", AI)

break

if (coin == 0):

print("BUST!")

human = 0

break

else:

option = input("Flip Again or Hold?")

def AI (): global AI

pot = 0

input("It's the computers turn. Hit ENTER to continue.")

while(pot<20):

coin= random.randint(0,2)

print("COINS : ",end= "")

if (coin == 1):

print("TTH ",end="")

elif (coin == 2):

print ("THH ",end="")

elif (coin == 3):

print("HHH ",end="")

else:

print("TTT ",end="")

pot = pot + coin

AI = AI + coin

print("Pot : ",pot, end="")

if (AI >=20):

print("Winner!")

print("SCORE: You: ",human," AI: ", AI)

break

if (coin == 0):

print("BUST!")

AI = 0 break def prompt():

choice = input("Do you want to play Greedy Coin again? (YES/Y/NO/N)")

if (choice.upper() == "YES" or choice.upper() =="Y"):

return 1;

elif(choice.upper() == "NO" or choice.upper()=="N"):

return 0;

else: prompt()

prev_turn = 0

while(1): turn = prev_turn

while(human <= 20 and AI <= 20):

print("SCORE: You :",human," AI: ", AI)

if(turn == 0):

Human() turn=1

else:

AI() turn=0

if(prompt()==0):

break

if(prev_turn==0):

prev_turn=1

else:

prev_turn=0

print("Game over!")

Its still not working that well-- any suggestions on how i can get it to work.. PYTHON Thank you so so much

Explanation / Answer

You did a great job. I just have modified some part of code.

import random

human= 0

AI = 0

print('WELCOME TO GREEDY DICE')

def prompt():

choice = input("Do you want to play Greedy Coin again? (YES/Y/NO/N)")

if (choice.upper() == "YES" or choice.upper()=="Y"):

pass

elif(choice.upper() == "NO" or choice.upper()=="N" ) :

print("Thank you!!")

exit()

else:

prompt()

def Human ():

global human

option= "f"

input("Your turn. Hit enter to continue.")

while (option == 'f' or option == 'F'):

pot = 0

coin= random.randint(0,3)

print("COINS : ",end= "")

if (coin == 1):

print("TTH ",end="")

elif (coin == 2):

print ("THH ",end="")

elif (coin == 3):

print("HHH ",end="")

else: print("TTT ",end="")

pot = pot + coin

human = human + coin

print("Pot : ",pot, end="")

if (human >=20):

print("Winner!")

print("SCORE: You: ",human," AI: ", AI)

break

if (coin == 0):

print("BUST!")

human = 0

AI = 0

prompt()

break

else:

option = input("Flip Again or Hold?")

def AIDo ():

global AI

pot = 0

input("It's the computers turn. Hit ENTER to continue.")

while(pot<8):

coin= random.randint(0,3)

print("COINS : ",end= "")

if (coin == 1):

print("TTH ",end="")

elif (coin == 2):

print ("THH ",end="")

elif (coin == 3):

print("HHH ",end="")

else:

print("TTT ",end="")

pot = pot + coin

AI = AI + coin

print("Pot : ",pot, end="")

if (AI >=20):

print("Winner!")

print("SCORE: You: ",human," AI: ", AI)

break

if (coin == 0):

print("BUST!")

AI = 0

human = 0

prompt()

break

prev_turn = 0

while(1):

turn = prev_turn

while(human <= 20 and AI <= 20):

print("SCORE: You :",human," AI: ", AI)

if(turn == 0):

Human()

turn=1

else:

AIDo()

turn=0

if(prev_turn==0):

prev_turn=1

else:

prev_turn=0

print("Game over!")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote