-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauto_battle.py
62 lines (50 loc) · 1.2 KB
/
auto_battle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
from io import StringIO
import contextlib
from referee.main import *
sys.argv = ["referee", "-v 0","ACCESS_GRANTED", "minimax_ab"]
exp_score = 50
t_weight = 100
f_weight = 1
e_weight = 1
def test_score(rounds):
upper = 0
lower = 0
draw = 0
result = []
for x in range(0,rounds):
out = main()
result.append(out)
print(out)
if "upper" in out:
upper +=1
elif "lower" in out:
lower +=1
else:
draw += 1
print("turn: ", x)
print("Upper win: ", upper)
print("lower win:", lower)
print("draw: ", draw)
print(result)
print("Upper win: ", upper)
print("lower win:", lower)
print("draw: ", draw)
return upper+0.5*draw
def learn_weight(weight, exp_score):
hist = 0
score = 0
test_weight = weight
step_size = 10
increase = True
while(score < exp_score):
score = test_score(100)
if (score<hist):
if increase:
weight -= step_size/2
increase = False
else:
weight += step_size/2
increase = True
hist = score
test_score(100)