4 This file is part of Arrocco, which is Copyright 2007 Thomas Plick
5 (tomplick 'at' gmail.com).
7 Arrocco is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 Arrocco is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 from position
import *
26 fen
= (sys
.argv
+ ["-"])[1]
29 def strangeKey((x
, y
)):
30 if x
== 'pv': return ('zzzzzzz', y
)
35 if fen
== '-': pos
= ipos
36 else: pos
= position(fen
)
39 for depth
in range(0, 1000):
42 result
= alphaBetaWithOldPV(pos
, depth
, oldVariation
= result
['pv'])
44 for (k
, v
) in sorted(result
.items(), key
= strangeKey
):
46 if k
== 'value' and pos
.turn
== 1:
48 print "%s: %s" % (k
, v
)
49 print "Variation: %s" % algebraicForPV(result
['pv'])
50 print "Took %s seconds" % (int(b
-a
)+1)
57 def alphaBetaWithOldPV2(pos
, depth
, oldVariation
):
58 arr
= (Position
* len(oldVariation
))()
60 children
= (Position
* (depth
* 512))()
63 value
= lib
.alphaBetaWithOldPV(ctypes
.byref(pos
), children
,
64 depth
, -99999, 99999, ctypes
.byref(counter
), arr
, len(oldVariation
))
68 for i
in range(depth
+ 1):
71 node
= node
.children()[self
.branch
[i
]]
75 return dict(depth
= depth
, value
= value
, pv
= L
, nodeCount
= counter
.value
)
78 if __name__
== '__main__':
79 thread
.start_new_thread(f
, ())