-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathall_vs_cheater.py
62 lines (60 loc) · 1.5 KB
/
all_vs_cheater.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 pickle
from framework import *
from holdem import *
from calling_station import Calling_station
from betting_station import Betting_station
import time
import numpy as np
import sys
from cheater_bot import Cheater_player
from threading import Thread, Lock, Semaphore
import os
lock = Lock()
numAvail = Semaphore(3)
path="./bots/"
data_name = "All_vs_cheater.txt"
class Worker(Thread):
def __init__(self, fname):
Thread.__init__(self)
self.fname = fname
def run(self):
global path, lock, numAvail, data_name
success = False
auto = None
data = ""
cheaterBot = Cheater_player()
if fname[-1]=='p':
try:
print path+fname
auto = pickle.load(open(path+fname, 'rb'))
#print "Passed"
success = True
except ImportError as e:
#pass
print e
if not success:
numAvail.release()
return
result = []
for i in range(5):
result.append(
auto.compete(cheaterBot, 1000, debug=0))
print 'File ',fname
print 'mean ', np.mean(result)
print 'std ', np.std(result)
print str(result)
print "============="
data+= 'File:' + fname
data+= 'mean:' + str(np.mean(result))
data+= 'std:' + str(np.std(result))
data+= str(result)
data+= "============="
with lock:
with open(data_name, 'a') as f:
f.write(data)
numAvail.release()
classes = ['pairStatus', 'anotherStatus', 'realizedStatus', 'coarserStatus']
dirList=os.listdir(path)
for fname in dirList:
numAvail.acquire()
Worker(fname).start()