Author | KendallHopkins |
Submission date | 2011-06-09 06:49:40.109724 |
Rating | 2231 |
Matches played | 5673 |
Win rate | 23.6 |
Use rpsrunner.py to play unranked matches on your computer.
import random
lose = 2
win = 1
tie = 0
unknown = -1
rpc = ['R','P','S']
if not input:
last_outcome = unknown
game_outcome = unknown
grid = [[0,0,0],[0,0,0],[0,0,0]]
output = random.choice(rpc)
else:
if last_outcome != unknown:
grid[last_outcome][(rpc.index( last_input )-rpc.index( input ))%3] += 1
last_outcome = game_outcome
game_outcome = (rpc.index( input ) - rpc.index( output )) % 3
last_input = input
if grid[last_outcome][0] > grid[last_outcome][1]:
if grid[last_outcome][0] > grid[last_outcome][2]:
output = rpc[1]
else:
output = rpc[0]
else:
if grid[last_outcome][1] > grid[last_outcome][2]:
output = rpc[2]
else:
output = rpc[0]