countingv2[Nile]

AuthorWDIFTL
Submission date2011-06-10 12:40:57.618721
Rating4776
Matches played5218
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("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))