Author | JustinF |
Submission date | 2011-06-15 09:12:35.695960 |
Rating | 3666 |
Matches played | 5149 |
Win rate | 34.63 |
Use rpsrunner.py to play unranked matches on your computer.
import random
encode = {'R': 0, 'P': 1, 'S': 2}
decode = {0: 'R', 1: 'P', 2: 'S'}
if not input:
turn = 0
oppStack = []
else:
turn += 1
oppStack.append(encode[input])
if turn < 2:
output = random.choice(('R', 'P', 'S'))
else:
output = decode[sum(oppStack[-2::]) % 3]