Author | Bottersnike |
Submission date | 2018-08-15 13:08:25.798830 |
Rating | 5912 |
Matches played | 273 |
Win rate | 60.81 |
Use rpsrunner.py to play unranked matches on your computer.
import random
KEY = 'SRRSPRPPSS'
ANTI = {'R': 'P', 'P': 'S', 'S': 'R'}
if input == "":
dna = ''
output = random.choice('RPS')
else:
if output != '':
dna += str(KEY.index(output + input))
for l in range(min(20, len(dna) - 1), 0, -1):
i = dna.rfind(dna[-l:], 0, -1)
if i != -1:
output = ANTI[KEY[int(dna[i + l]) + 1]]
else:
output = random.choice('RPS')