This program has been disqualified.
Author | Eppie |
Submission date | 2020-02-02 04:18:53.499817 |
Rating | 6280 |
Matches played | 9 |
Win rate | 77.78 |
import random
from collections import defaultdict, deque
if not input:
max_context = 150
history = deque(maxlen=max_context)
moves = ['R', 'P', 'S']
counters = {'R': 'P', 'P': 'S', 'S': 'R'}
table = defaultdict(lambda: {'R': 0, 'P': 0, 'S': 0})
output = random.choice(moves)
else:
recent_history = deque(history)
while recent_history:
current_context = tuple(recent_history)
table[current_context][input] += 1
recent_history.popleft()
history.append(input)
recent_history = deque(history)
while recent_history:
current_context = tuple(recent_history)
counts = table[current_context]
if counts['R'] != 0 or counts['P'] != 0 or counts['S'] != 0:
break
recent_history.popleft()
v, k = max((v, k) for k, v in counts.items())
output = counters[k]