Author | ... |
Submission date | 2019-12-10 00:25:43.952981 |
Rating | 7223 |
Matches played | 210 |
Win rate | 71.9 |
Use rpsrunner.py to play unranked matches on your computer.
import random
wbt = {"R":"P","P":"S","S":"R"}
def move(my,th):
if len(my) < 1:
return 'S'
pat = []
cu = my[-1]+th[-1]
for i in range(len(my)-1):
c = my[i]+th[i]
if c == cu:
pat.append(th[i+1])
if len(pat) > 0:
return wbt[random.choice(pat)]
else:
return wbt[th[random.randint(0,len(th)-1)]]
if input == "":
m = ""
t = ""
else:
t +=input
x = move(m,t)
m+=x
output = x