{{ message }}

Instantly share code, notes, and snippets.

# mjhea0/first-to-five-winners.md Secret

Last active Nov 19, 2017

Winners, in no particular order...

 def computer_strategy(scores, player_answers, computer_answers, total_iterations, current_iteration): v = [] # counter of values expected = [] # expected values of scores for i in range(10): v.append(1) expected.append(0) for i in player_answers: i = i - 1 if i < 0: i = 0 if i > 9: i = 9 v[i] = v[i] + 1 # compute expected value # computer chooses i # adversary chooses j for i in range(10): for j in range(10): score = 1 if i + 1 == j: score = -2 elif i - 1 == j: score = 2 elif i == j: score = 0 elif j < i: score = -1 expected[i] = expected[i] + score * v[j] best = 1 maxi = -10000000 # -INF for i in range(10): if expected[i] > maxi: maxi = expected[i] best = i + 1 return best
 def computer_strategy(scores, player_answers, computer_answers, total_iterations, current_iteration): import random offset = random.randrange(0, 2) scale = random.randrange(0, player_answers[-1] if player_answers else 1) avg = sum(player_answers) // (current_iteration + 1) aggression = scores['player'] - scores['computer'] return 1 if aggression > scale else random.randrange(1, avg+2) + offset