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