I want to write a function simul() that takes an integer and simulates n rounds of Rock,Paper,Scissors between Player1 and Player2. The player who wins the most rounds wins the n-round game, with ties possible.
Example:
simul(1) Player1
simul(1) Tie
simul(100) Player2
I've written:
def rps():
lst['R', 'P', 'S']
p1=random.choice(lst)
p2=random.choice(lst)
if p1+p2=='RS' or p1+p2=='PR' or p1+p2=='SP':
return '-1'
elif p1+p2=='RP' or p1+p2=='PS' or p1+p2=='SR':
return '1'
else:
return '0'
def simul(n):
total=0
for i in range(n):
if rps()==-1:
total+=-1
elif rps()==1:
total+=1
else:
total+=0
if total<0:
print('Player1')
elif total==0:
print('Tie')
else:
print('Player2')
When I run the simul() code, however, the only result I ever get is 'Tie'. How can I fix it??