Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Made by Ivan Petrin
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.