ppm6

This program has been disqualified.


AuthorEppie
Submission date2020-02-02 02:53:57.101649
Rating5000
Matches played0
Win rate0

Source code:

import random
from collections import defaultdict

if not input:
    history = []
    moves = ['R', 'P', 'S']
    counters = {'R': 'P', 'P': 'S', 'S': 'R'}
    max_context = 180
    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]