Author | WDIFTL |
Submission date | 2011-06-10 12:40:57.618721 |
Rating | 4776 |
Matches played | 5218 |
Win rate | 49.18 |
Use rpsrunner.py to play unranked matches on your computer.
import random
game = ["R","P","S"]
if input=="":
matchHistory=[[],[]]
countHim = [0,0,0]
matchNumber=0
output = random.choice(game)
else:
++matchNumber
matchHistory[1].append(game.index(input))
if matchNumber<100:
output=random.choice(game)
else:
countHim=[matchHistory[1].count("R"),matchHistory[1].count("P"),matchHistory[1].count("S")]
if (max(countHim)/matchNumber)<.35:
output=random.choice(game)
else:
output = game[(countHim.index(max(countHim))+1)%3]
matchHistory[0].append(game.index(output))