This program has been disqualified.

Authorben haley
Submission date2012-07-28 19:29:41.439701
Matches played40
Win rate60.0

Source code:

Using compression to predict the opponents most likely next move.

The most likely move is assumed to be the one that with the least
complexity (least randomness) and therefore the one that has the
smallest compression size when added to the string representation
of previous moves.

bmh July 2012 <>

from zlib import compress
from random import shuffle, choice, random

    moves = {

    comebacks = {
        ('rock',): ('paper',),
        ('paper',): ('scissors',),
        ('scissors',): ('rock',),
        ('paper', 'rock'): ('paper',),
        ('paper', 'scissors'): ('scissors',),
        ('rock', 'scissors'): ('rock',),
        ('paper', 'rock', 'scissors'): ('paper', 'rock', 'scissors'),
    rmoves = dict((v.upper(), k) for k, v in moves.items())

def complexity(string):
    """ What is the compressed size of a string?
    (larger is more complex)"""
    return len(compress(string, 9))

def get_move_string(my_moves, opp_moves):
    """translate a list of moves into a compressible string"""
    return ''.join([moves[me] + moves[opp] for me, opp in zip(my_moves, opp_moves)])

def expected(my_moves, opp_moves):
    """The most likely next move of the opponent"""
    history = get_move_string(opp_moves, my_moves)
    exps = [(complexity(history + moves[m]), m) for m in moves.keys()]
    brilliance = exps[0][0] / float(complexity(history + moves.keys()[0]))
    patients = 0 if brilliance < 0.90 else \
               1 if brilliance < 0.96 else \
    res = tuple(sorted([e[1] for e in exps if e[0] <= min(exps)[0] + patients]))
    return res

def player(my_moves, opp_moves):
    return choice(comebacks[expected(my_moves, opp_moves)])

def shuffle_(string):
    array = list(string)
    return ''.join(array)

# to compare with existing code at
if input == "":
    my_moves = []
    opp_moves = []
    opp_moves += [rmoves[input]]

my_move = player(my_moves, opp_moves)
output = my_move[0].upper()