This program has been disqualified.
Author | Smetalo |
Submission date | 2012-07-28 14:22:06.221883 |
Rating | 6084 |
Matches played | 77 |
Win rate | 61.04 |
import random
if input == "":
opp_moves=[]
my_moves=[]
follows={}
choices=['P', 'S', 'R']
winner={'R': 'P', 'P': 'S', 'S': 'R'}
output=random.choice(choices)
else:
opp_moves.append(input)
my_moves.append(output)
if len(opp_moves)<5:
output=random.choice(choices)
else:
lastMoves=opp_moves[len(opp_moves)/2:]
found=False
for i in range(1,len(lastMoves)*3/5):
found=True
for j in range(len(lastMoves)-i):
if lastMoves[j]!=lastMoves[j+i]:
found=False
break
if found==True:
output=winner[lastMoves[len(lastMoves)-i]]
break
if found==False:
i=len(opp_moves)-5
x=opp_moves[i]
y=opp_moves[i+1]
z=opp_moves[i+2]
w=opp_moves[i+3]
v=opp_moves[i+4]
a=my_moves[i]
b=my_moves[i+1]
c=my_moves[i+2]
d=my_moves[i+3]
e=my_moves[i+4]
t=(x,a,y,b,z,c,w,d)
if t not in follows:
follows[t]={}
follows[t][0]={}
follows[t][1]={}
if e not in follows[t][0]:
follows[t][0][e]=1
else:
follows[t][0][e]+=1
if v not in follows[t][1]:
follows[t][1][v]=1
else:
follows[t][1][v]+=1
his_last=opp_moves[-1]
one_before_his_last=opp_moves[-2]
two_before_his_last=opp_moves[-3]
three_before_his_last=opp_moves[-4]
my_last=my_moves[-1]
one_before_my_last=my_moves[-2]
two_before_my_last=my_moves[-3]
three_before_my_last=my_moves[-4]
the_end=(three_before_his_last,three_before_my_last,two_before_his_last,two_before_my_last, one_before_his_last,one_before_my_last, his_last, my_last)
if the_end in follows:
maxim=0
solution=-1
stats=follows[the_end][0]
for i in stats:
current=stats[i]
if current>maxim:
maxim=current
solution=i
his_guess=solution
maxim=0
solution=-1
stats=follows[the_end][1]
for i in stats:
current=stats[i]
if current>maxim:
maxim=current
solution=i
my_guess=winner[solution]
if his_guess==my_guess:
random.shuffle(choices)
for x in choices:
if x!=my_guess:
output=x
break
else:
output=my_guess
else:
output=random.choice(choices)