Author | AntiDog |
Submission date | 2018-08-08 07:54:55.531680 |
Rating | 2441 |
Matches played | 285 |
Win rate | 22.11 |
Use rpsrunner.py to play unranked matches on your computer.
if input == "":
output = "P"
oponentmoves = ""
else:
oponentmoves += input
if(len(oponentmoves) > 75):
oponentmoves = oponentmoves[:75]
r = 0
p = 0
s = 0
for i in range(2,len(oponentmoves)):
searchsequence = oponentmoves[len(oponentmoves)-i:]
nextresults = oponentmoves.split(searchsequence)
k = 0
weight = 1.0
for res in nextresults:
n = 1
k+=1
weight = 1/i
if k == 1:
continue
if res == "":
res = searchsequence
n = len(",".join(oponentmoves.split(searchsequence)))
if res[0] == "R":
r += n *weight
elif res[0] == "P":
p += n *weight
elif res[0] == "S":
s += n *weight
else:
continue
if r >= p and r >= s:
output = "P"
next = "R"
elif p >= s and p >= r:
output = "S"
next = "P"
else:
output = "R"
next = "S"