Author | KendallHopkins |
Submission date | 2011-06-09 06:54:32.514703 |
Rating | 2398 |
Matches played | 5313 |
Win rate | 22.83 |
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]
if random.randint(0,127) == 0:
for x in range(0, 2):
for y in range(0, 2):
grid[x][y] /= 10