Author | vytah |
Submission date | 2013-10-01 23:13:15.268459 |
Rating | 4994 |
Matches played | 657 |
Win rate | 49.92 |
Use rpsrunner.py to play unranked matches on your computer.
import random
CHOICE_TO_STRING = ['R', 'P', 'S']
STRING_TO_CHOICE = {'R': 0, 'P': 1, 'S': 2}
MEM = [0] * 9
M = []
J = []
if input == '':
o = random.choice([0,1,2])
else:
J.append(STRING_TO_CHOICE[input])
if len(J)<2:
o = random.choice([0,1,2])
else:
MEM[M[-2] * 3 + J[-2]] = J[-1]
o = (MEM[M[1] * 3 + J[-1]] + 1) % 3
M.append(o)
output = CHOICE_TO_STRING[o]