Author | WDIFTL |
Submission date | 2011-06-10 17:21:23.471640 |
Rating | 5610 |
Matches played | 5115 |
Win rate | 53.47 |
Use rpsrunner.py to play unranked matches on your computer.
import random
game = ["R","P","S"]
if input=="":
matchHistory=[[],[]]
matchNumber=0
output = random.choice(game)
else:
matchNumber=matchNumber+1
matchHistory[1].append(game.index(input))
countHim=[matchHistory[1].count(0),matchHistory[1].count(1),matchHistory[1].count(2)]
if float(max(countHim))/float(matchNumber)<.37 or matchNumber<100:
output=random.choice(game)
else:
if matchHistory[1][matchNumber-1]==matchHistory[1][matchNumber-2]==matchHistory[1][matchNumber-3]:
output = game[(matchHistory[1][matchNumber-1]+1)%3]
else:
output = game[(countHim.index(max(countHim))+1)%3]
matchHistory[0].append(game.index(output))