hi so i need to write a rock paper scissors game. when played in the command prompt it should look something like this
user input is in bold
press q at any time to quit
please choose rock(r), paper(p) or scissors(s): r
computer chose paper. you lose!
your score: 0 win(s), 1 loss(es), and 0 tie(s)
and it continues until you quit.
and please dont say how because this looks like an assignment youre not going to help me out. im not asking for the answers but rather tips or pointers in helping me make this work. thanks. :)
what im having problems on is looping all these functions together. and i dont understand how i can make the scores go up. if you could help me it would be greatly appreciated :)
heres my code:
[import random
x=('p','s','r')
def beats(throw):
if throw=='r':
return'p'
if throw=='p':
return 's'
if throw=='s':
return'r'
def winning_move(throw1, throw2):
if throw1==throw2:
return 'tie'
if throw1=='win':
return throw1
if throw2=='win':
return throw2
def me_vs_you(me, you):
if me=='r' and you=='s':
return 'win'
elif me=='s' and you== 'r':
return 'lose'
elif me=='r' and you=='p':
return 'lose'
elif me=='p' and you=='r':
return 'win'
elif me=='p' and you=='s':
return 'lose'
elif me=='s' and you=='p':
return 'win'
elif me=='s' and you=='s':
return 'tie'
elif me=='p' and you=='p':
return 'tie'
elif me=='r' and you=='r':
return 'tie'
def play_random_game():
if me_vs_you(me,you)=='win':
return 'win'
if me_vs_you(me, you)=='lose':
return 'lose'
if me_vs_you(me, you)=='tie':
return 'tie'
def count_games(num):
text=''
a=0
b=0
c=0
while play_random_game(x)=='win':
a +=1
while play_random_game(x)=='lose':
b +=1
while play_random_game(x)=='tie':
c +=1
def play_RPS(x):
print 'Press q at any time to quit'
text=''
while text!='q':
text=raw_input("Please choose rock(r), paper(p), or scissors(s):")
if text=='q':
print "Thanks for playing!"
break
elif text== 'r':
random_throw=random.choice(x)
print random_throw
elif text=='s':
random_throw=random.choice(x)
print random_throw
elif text=='p':
random_throw=random.choice(x)
print random_throw
else:
print "Invalid input!"]