How would I go about adding a computer opponent to my pig dice game? /u/Mewnium69420 Python Education

import random

command = “”

turns = 0

totalScore = 0

turnScore = 0

while totalScore < 100:

print(“Turn: {} Score: {} in {} turns.”.format(turnScore, totalScore, turns))

command = input(“command> “).lower()

if command == “roll”:

roll = random.randint(1,6)

if roll == 1:

print(“You rolled a 1! Oh no!”)

turnScore = 0

turns = turns + 1

else:

turnScore = turnScore + roll

elif command == “hold”:

print(“You’ve ended your turn!”)

totalScore = totalScore + turnScore

turnScore = 0

turns = turns + 1

elif command == “quit”:

print(“Bye!”)

break;

else:

print(“What?”)

print(“FINAL SCORE: {} in {} turns ({})”.format(totalScore, turns, totalScore/turns))

if totalScore > 99:

print(“You win!”)

submitted by /u/Mewnium69420
[link] [comments]

​r/learnpython import random command = “” turns = 0 totalScore = 0 turnScore = 0 while totalScore < 100: print(“Turn: {} Score: {} in {} turns.”.format(turnScore, totalScore, turns)) command = input(“command> “).lower() if command == “roll”: roll = random.randint(1,6) if roll == 1: print(“You rolled a 1! Oh no!”) turnScore = 0 turns = turns + 1 else: turnScore = turnScore + roll elif command == “hold”: print(“You’ve ended your turn!”) totalScore = totalScore + turnScore turnScore = 0 turns = turns + 1 elif command == “quit”: print(“Bye!”) break; else: print(“What?”) print(“FINAL SCORE: {} in {} turns ({})”.format(totalScore, turns, totalScore/turns)) if totalScore > 99: print(“You win!”) submitted by /u/Mewnium69420 [link] [comments] 

import random

command = “”

turns = 0

totalScore = 0

turnScore = 0

while totalScore < 100:

print(“Turn: {} Score: {} in {} turns.”.format(turnScore, totalScore, turns))

command = input(“command> “).lower()

if command == “roll”:

roll = random.randint(1,6)

if roll == 1:

print(“You rolled a 1! Oh no!”)

turnScore = 0

turns = turns + 1

else:

turnScore = turnScore + roll

elif command == “hold”:

print(“You’ve ended your turn!”)

totalScore = totalScore + turnScore

turnScore = 0

turns = turns + 1

elif command == “quit”:

print(“Bye!”)

break;

else:

print(“What?”)

print(“FINAL SCORE: {} in {} turns ({})”.format(totalScore, turns, totalScore/turns))

if totalScore > 99:

print(“You win!”)

submitted by /u/Mewnium69420
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *