max_latest_3_compliment

Authorcuriouscat
Submission date2012-12-21 04:31:56.805670
Rating1603
Matches played745
Win rate15.3

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

Source code:

import random

def most_common(l):
    max = 0
    maxitem = None
    for x in set(l):
        count =  l.count(x)
        if count > max:
            max = count
            maxitem = x
    return maxitem

if input == "": # initialize variables for the first round
        history=''
        history += random.choice(['R','P','S'])
        history += random.choice(['R','P','S'])
        history += random.choice(['R','P','S'])


history += input

guess=most_common(history[-3:-1])

if guess == "R":
	output = "S"
elif guess == "P":
	output = "R"
else:
	output = "P"