countv5[Nile]

AuthorWDIFTL
Submission date2011-06-10 13:12:48.520344
Rating4920
Matches played5578
Win rate49.18

Use rpsrunner.py to play unranked matches on your computer.

Source code:

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(0),matchHistory[1].count(1),matchHistory[1].count(2)]
    if (max(countHim)/matchNumber)<.35:
      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))