This program has been disqualified.
Author | Eppie |
Submission date | 2020-02-02 02:54:59.950187 |
Rating | 5412 |
Matches played | 1 |
Win rate | 100.0 |
import random
from collections import defaultdict
if not input:
history = []
moves = ['R', 'P', 'S']
counters = {'R': 'P', 'P': 'S', 'S': 'R'}
max_context = 188
table = defaultdict(lambda: {'R': 0, 'P': 0, 'S': 0})
output = random.choice(moves)
else:
max_context_len = min(len(history), max_context)
for context_len in range(max_context_len, 0, -1):
current_context = tuple(history[-context_len:])
table[current_context][input] += 1
history.append(input)
max_context_len = min(len(history), max_context)
for context_len in range(max_context_len, 0, -1):
current_context = tuple(history[-context_len:])
counts = table[current_context]
if counts['R'] != 0 or counts['P'] != 0 or counts['S'] != 0:
break
v, k = max((v, k) for k, v in counts.items())
output = counters[k]