Ok, I won't delay this any longer. I was trying to tweak it to try to out-smart Ichabod's sirius bot, but it's taken longer than I thought, and I said I'd add a little something to help kick us off, so here's my entry.
The first thing to note, is that it follows a set strategy very stringently. Three strategies, in fact. So the first thing it does when it's called, is figure out if it's in the middle of a strategy, and if it is, it responds with the next step in that strategy. If it's NOT in the middle of a strategy (ie, every 3rd round), then it calculates it's current performance, and bases it's next strategy off of that. So if it's losing, it uses one strat, if it's winning, a different one, and if the scores are perfectly tied (ie: the very first round) a third strategy. In general, I like this approach, so I'll probably continue to tweak it to try to figure out a way around ichabod's predictive analysis.
The first thing to note, is that it follows a set strategy very stringently. Three strategies, in fact. So the first thing it does when it's called, is figure out if it's in the middle of a strategy, and if it is, it responds with the next step in that strategy. If it's NOT in the middle of a strategy (ie, every 3rd round), then it calculates it's current performance, and bases it's next strategy off of that. So if it's losing, it uses one strat, if it's winning, a different one, and if the scores are perfectly tied (ie: the very first round) a third strategy. In general, I like this approach, so I'll probably continue to tweak it to try to figure out a way around ichabod's predictive analysis.
# nilabot - nilamo import sys winning_match = {'R':'S', 'P':'R', 'S':'P'} lookup = {} # indexes match our current record... 0=tied, 1=winning, -1=losing strategies = ['PRP', 'RSR', 'SPR'] ''' lookup will end up looking like... RR: 0, RS: 1, RP: -1 for all 9 combinations. 0 is a tie, -1 a loss, +1 a win ''' def populate_lookup(): for left, loser in winning_match.items(): for right in winning_match.keys(): result = 0 if right == loser: result = 1 elif left != right: result = -1 lookup[left+right] = result def current_results(rounds): return sum(lookup[round] for round in rounds) def current_strategy(rounds): current_strategy_length = len(rounds) % 3 if current_strategy_length: strat_starts_with = rounds[-current_strategy_length][0] for strategy in strategies: if strategy.startswith(strat_starts_with): return strategy[current_strategy_length] return None def get_response(rounds): strategy = current_strategy(rounds) # if we're in the middle of a strategy, keep going with it if strategy: return strategy # find out which strategy we should start next populate_lookup() record = current_results(rounds) ndx = 0 if record == 0 else 1 if record > 0 else -1 response = strategies[ndx][0] return response if __name__ == '__main__': rounds = sys.argv[1:] print(get_response(rounds))