lots
[arrocco.git] / partest.py
blob922620b4398221cf6f58c8f7e4d39f2e5b0470fd
1 # partest.py
2 # 21 June 2007
4 from position import *
5 from search import *
6 import sys, thread, time, os
8 try:
9 fen = sys.argv[1]
10 pos = position(fen)
11 except:
12 pos = ipos
14 def removePV(res):
15 x = res.copy()
16 del x['pv']
17 return x
19 def main(Max = 32):
20 for d in range(Max):
21 print "\nDepth %s:" % d
22 if 'CLEAR' in os.environ:
23 pvCache.clear()
24 if 'PARALLEL' in os.environ:
25 splits = 1
26 else:
27 splits = 0
28 x = alphaBeta(pos, d, top = True, splits = splits)
29 print " ", removePV(x)
30 print " ", algebraicForPV(x['pv'])
32 def main2(Max = 32):
33 global pvCache
34 otherPVCache = {}
35 times = [1, 1]
37 for d in range(Max):
38 print "\nDepth %s:" % d
39 for splits in (0, 1):
40 x = alphaBeta(pos, d, top = True, splits = splits)
41 print ["no split", "one split"][splits]
42 print " ", removePV(x)
43 print " ", algebraicForPV(x['pv'])
45 times[splits] = x['time']
46 pvCache, otherPVCache = otherPVCache, pvCache
47 speedup = float(times[0]) / times[1]
48 print "Speed-up: %.2fx (ratio: %.1f%%)" % (speedup, 100.0 /
49 speedup)
51 if __name__ == '__main__':
52 thread.start_new_thread(main2, ())
53 while 1:
54 time.sleep(1000)