This program has been disqualified.
Author | scoppini |
Submission date | 2015-07-01 23:23:17.655012 |
Rating | 5325 |
Matches played | 218 |
Win rate | 52.75 |
import random
if not input:
opp_history = ''
output = random.choice('RPS')
else:
opp_history += input
throw = ''
for length in range(min(len(opp_history)/2-1,10),0,-1):
last_throws = opp_history[-length:]
occurences = []
for i in range(len(opp_history)-length):
if opp_history[i:i+length] == last_throws:
occurences.append(i)
if occurences:
prob_throws = [opp_history[place+1] for place in occurences]
r, p, s = prob_throws.count('R'), prob_throws.count('P'), prob_throws.count('S')
if r > max(p, s): throw = 'P'
elif p > max(r, s): throw = 'S'
elif s > max(r, p): throw = 'R'
elif r==p==s: throw = random.choice('RPS')
elif r == s: throw = random.choice('PS')
elif p==s: throw = random.choice('SR')
else: throw = random.choice('RP')
break
output = throw if throw else random.choice('RPS')