-
Notifications
You must be signed in to change notification settings - Fork 0
/
tournoi.py
99 lines (95 loc) · 2.06 KB
/
tournoi.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
from os import popen
from threading import Thread
import time
def main():
global somme, somme2, total, win, win2
popen("make")
somme = 0
total = 0
somme2 = 0
win = 0
win2 = 0
N = 200
class truc(Thread):
def run(self):
global somme, somme2, total, win, win2
f = popen("stechec2-run config4.yml")
score_old = -1000;
while True:
line = f.readline()
if "player: Ancien" in line:
line2 = f.readline()
score = int(line2[7:])
somme2 += score
score_old = score
print(score)
if "player: Nouveau" in line:
line2 = f.readline()
score = int(line2[7:])
somme += score
if(score_old > score):
win2 += 1
elif(score_old < score):
win += 1
elif(score_old == score):
win2 += 0.1
win += 0.1
total += 1
print("------- (old vs new)")
print("old: ", somme2/total)
print("new: ", somme/total)
print("diff: ",somme/total - somme2/total)
print("old: ", win2)
print("new: ", win)
break
time.sleep(1)
f.close()
class truc2(Thread):
def run(self):
global somme, somme2, total, win, win2
f = popen("stechec2-run config5.yml")
score_nv = -1000;
while True:
line = f.readline()
if "player: Nouveau" in line:
line2 = f.readline()
score = int(line2[7:])
somme += score
score_nv = score
if "player: Ancien" in line:
line2 = f.readline()
score = int(line2[7:])
somme2 += score
if(score_nv < score):
win2 += 1
elif(score_nv > score):
win += 1
elif(score_nv == score):
win2 += 0.1
win += 0.1
total += 1
print("------- (new vs old)")
print("old: ", somme2/total)
print("new: ", somme/total)
print("diff: ",somme/total - somme2/total)
print("old: ", win2)
print("new: ", win)
break
time.sleep(1)
f.close()
for _ in range(N):
a = truc()
a.start()
time.sleep(0.1)
a = truc2()
a.start()
time.sleep(0.1)
a = truc()
a.start()
time.sleep(0.1)
a = truc2()
a.start()
time.sleep(3)
while total < N:
time.sleep(0.5)
main()