stest3

Authorsecret
Submission date2015-02-09 17:03:19.703215
Rating3658
Matches played550
Win rate34.73

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

Source code:

import random

nf=1

if input == "": 
    lm = [1] * 27
    e = m = nf = 0
else:
    e=(e%3)*3
    if input == "R":
        e += 0
    elif input == "P":
        e += 1
    elif input == "S":
        e += 2

if nf:
    lm[m * 9 + e] += 1
    
lmc=[0]*27
sc=0

for i in range(27):
    lmc[i]=int(lm[i]**0.5)
    sc+=lmc[i]
    
ra=random.randrange(sc)

for i in range(27):
    ra-=lmc[i]
    if ra<0:
        break

s=(i+1)%3
    
if s==0:
    output = "P" # paper beats rock
    m=0
elif s==1:
    output = "S" # scissors beats paper
    m=1
else:
    output = "R" # rock beats scissors
    m=2