qb6

Authormonkey
Submission date2012-08-17 08:38:31.653059
Rating2122
Matches played773
Win rate21.22

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

Source code:

import random

CHOICES = ['R', 'P', 'S']
BEATS = {'R' : 'P', 'P' : 'S', 'S' : 'R'}
if input == "":
  output = random.choice(CHOICES)
  distribution = {'R' : {'R' : 1, 'P': 1, 'S' : 1}, 'P' : {'R' : 1, 'P': 1, 'S' : 1}, 'S' : {'R' : 1, 'P': 1, 'S' : 1}}
  count = 1
else:
  count += 1 
  if output == "":
      output = random.choice(CHOICES)
  distribution[output][input] += (10 - random.randint (1,8))
  if count > 20:
    (a, b, s) = (1,1,'R')
    for my_strategy in CHOICES:
      opponent_strategy = BEATS[my_strategy]
      c = distribution[my_strategy][opponent_strategy]
      d = sum(distribution[my_strategy].values())
      if a * d > b * c:
	(a,b,s) = (c,d,my_strategy)
    output = s