Author | RyanC |
Submission date | 2012-10-03 23:48:01.462985 |
Rating | 5111 |
Matches played | 735 |
Win rate | 48.71 |
Use rpsrunner.py to play unranked matches on your computer.
# This one actually works
from hashlib import sha256
throws = ['R', 'P', 'S']
# Initialize state with carefully chosen constant.
if input == '':
state = 'I win against bots that always throw the same thing!'
else:
state = state + input
# Choose a throw deterministically based on opponent's throws so far.
output = throws[int(sha256(state).hexdigest(), 16) % len(throws)]