/count_to_five_bot.py Secret
Created
October 16, 2015 14:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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