Trying to remove tilde files again
[arrocco.git] / main.py
blob0d569ab1cd496d89892bab75286ed0be726d9689
2 from position import *
3 import thread, time
5 import sys, os
7 fen = (sys.argv + ["-"])[1]
10 def strangeKey((x, y)):
11 if x == 'pv': return ('zzzzzzz', y)
12 else: return (x, y)
15 def f():
16 if fen == '-': pos = ipos
17 else: pos = position(fen)
19 result = {'pv' : []}
20 for depth in range(0, 1000):
21 print "\n"
22 a = time.time()
23 result = alphaBetaWithOldPV(pos, depth, oldVariation = result['pv'])
24 b = time.time()
25 for (k, v) in sorted(result.items(), key = strangeKey):
26 if k != 'pv':
27 if k == 'value' and pos.turn == 1:
28 v *= -1
29 print "%s: %s" % (k, v)
30 print "Variation: %s" % algebraicForPV(result['pv'])
31 print "Took %s seconds" % (int(b-a)+1)
33 global running
34 running = False
35 sys.exit(0)
38 def alphaBetaWithOldPV2(pos, depth, oldVariation):
39 arr = (Position * len(oldVariation))()
40 arr[:] = oldVariation
41 children = (Position * (depth * 512))()
42 counter = int64(0)
44 value = lib.alphaBetaWithOldPV(ctypes.byref(pos), children,
45 depth, -99999, 99999, ctypes.byref(counter), arr, len(oldVariation))
47 L = []
48 node = pos
49 for i in range(depth + 1):
50 L.append(node)
51 try:
52 node = node.children()[self.branch[i]]
53 except:
54 pass
56 return dict(depth = depth, value = value, pv = L, nodeCount = counter.value)
58 running = True
59 if __name__ == '__main__':
60 thread.start_new_thread(f, ())
61 while running:
62 time.sleep(1000)