horny_lama_stateChange

Authorhorny_lama
Submission date2015-05-04 16:39:15.546562
Rating5527
Matches played510
Win rate53.33

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

Source code:

import random

if input=="":
    beats={'R':'P', 'P':'S', 'S':'R'}
    last=random.sample(['R','P','S'],1)[0]
    myLast=''
    state=random.randint(0,2)

    score=0
    longScore=0
    roundNum=0

else:
    last=input

    if roundNum>100 and (longScore*1./roundNum)<min(-1+.1*roundNum/100, -.1):
        state=-1
    else:
        if beats[myLast]==last:
            score-=1
            longScore-=1
        if beats[last]==myLast:
            score+=1
            longScore-=1

        if score<=0 and roundNum%5==0:
            state=(state+1)%3
            score=0

        roundNum+=1
    
if state==0:
    temp=last
elif state==1:
    temp=beats[last]
elif state==2:
    temp=beats[beats[last]]
else:
    temp=random.sample(['R','P','S'],1)[0]

myLast=temp
output=temp