ppm8

This program has been disqualified.


AuthorEppie
Submission date2020-02-02 04:18:53.499817
Rating6280
Matches played9
Win rate77.78

Source code:

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]