Author | seb |
Submission date | 2019-10-16 12:34:41.832791 |
Rating | 2360 |
Matches played | 221 |
Win rate | 23.53 |
Use rpsrunner.py to play unranked matches on your computer.
import random
def getNextMove(string):
for i in range(len(string) - 1, 0, -1):
temp = string[-i:]
if string.find(temp) + i < len(string) and i + 1 < len(string):
return string[i + 1]
return ""
previous = input
if previous == "":
pattern = "RPS"
def beat(choise):
if choise == "R":
return "P"
elif choise == "P":
return "S"
else:
return "R"
if previous != "":
pattern += previous
nextMove = getNextMove(pattern[-500:])
if nextMove == "":
output = beat(random.choice(pattern))
else:
output = nextMove