Author | KINGKARL |
Submission date | 2015-11-03 02:33:07.539749 |
Rating | 5149 |
Matches played | 460 |
Win rate | 48.91 |
Use rpsrunner.py to play unranked matches on your computer.
import random
com = 0
ans = ['R','P','S']
usr_results = []
ran = 3
def calc():
r = usr_results.count(0)
p = usr_results.count(1)
s = usr_results.count(2)
if r > p and r > s:
return 1
elif p > s:
return 2
else:
return 0
choice = random.sample(range(ran), 1)
if choice[0] >= 3:
com = num
elif choice[0] != 3:
com = choice[0]
if com == 0:
output = ans[0]
elif com == 1:
output = ans[1]
elif com == 2:
output = ans[2]
usr = input
if usr == ans[0]:
usr = 0
elif usr == ans[1]:
usr = 1
else:
usr = 2
usr_results.append(usr)
if len(usr_results) >= 4:
num = calc()
ran = 5