mem3

Authormsuvakov
Submission date2017-04-30 22:08:33.580010
Rating5794
Matches played358
Win rate57.54

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

Source code:

import random
output = random.choice(["R","P","S"])

if not input:
    i=0
    beat={'R':'P','P':'S','S':'R'}
    output = random.choice(["R","P","S"])
    omoves=[]
    mmoves=[output]
else:
    omoves.append(input)
    i=i+1
    if i<500:
        output = random.choice(["R","P","S"])
    else:
        hist={}
        for i in range(len(omoves)-3):
            s=omoves[i]+mmoves[i]+omoves[i+1]+mmoves[i+1]+omoves[i+2]+mmoves[i+2]+omoves[i+3]
            if s in hist:
                hist[s]=hist[s]+1
            else:
                hist[s]=1
        s0=omoves[-3]+mmoves[-3]+omoves[-2]+mmoves[-2]+omoves[-1]+mmoves[-1]
	if s0+"R" in hist:
        	r=hist[s0+"R"]
	else:
		r=0
	if s0+"S" in hist:
        	s=hist[s0+"S"]
	else:
		s=0
	if s0+"P" in hist:
        	p=hist[s0+"P"]
	else:
		p=0
        if r>s:
            if r>p:
                pred="R"
            else:
                pred="P"
        else:
            if s>p:
                pred="S"
            else:
                pred="P"
            
        output = beat[pred]        
    mmoves.append(output)