root/06/devel-old/ktest.py

Revision 175, 1.6 kB (checked in by ug, 2 years ago)

Done some more work on pattern.cc; seems to work now.

  • Property svn:executable set to *
Line 
1 #! /usr/bin/env python
2
3 import time
4 import os
5 import sys
6 import cPickle
7 from copy import copy, deepcopy
8 from string import split, find, join, strip, replace, digits, maketrans, translate, lower, upper
9 import glob
10 import re
11 from array import *
12 import webbrowser
13
14 from abstractBoard import *
15 from board import *
16 from searchPY import *
17 from aglPY import *
18 from algosPY import *
19 try:
20     from pattern import *
21 except:
22     print "Using patternPY"
23     from patternPY import *
24
25 # process sgf files in ./testdata
26
27 # test "process" directly
28
29 # progBar = dummy_progbar()
30 # db = SGFDatabase(19, progBar)
31 # ALGOS = 255
32 # db.process('./testdata', ('./testdata', ''), ALGOS, '*.sgf', )
33
34 # ----------------------------------------------------------
35
36 # test abstractGameList
37  
38 agl = abstractGameList()
39 agl.addDB('./testdata', ('./testdata', ''), stdout_message())
40
41 # ----------------------------------------------------------
42
43 # set up a search pattern
44
45 p = Pattern(0, 13, 0, 14,
46             5, 4,
47             '..XO.'+
48             '..OX.'+
49             '.....'+
50             '.....',
51             '', 0, 'X')
52
53 p.printPattern()
54
55 # do pattern search
56
57 noMatches, Bwins, Wwins, noSwitched, continuations = \
58       agl.search(p, {}, 0, {}, ['A', 'B', 'C', 'D', 'E', 'F', 'G'])
59
60 print
61 print 'Search results'
62 print 'Number of matches: ', noMatches
63 print 'Black wins: ', Bwins
64 print 'White wins: ', Wwins
65 print 'Number of color reversals: ', noSwitched
66 print 'Continuations:'
67 for k in continuations.keys(): print k, ': ', continuations[k]
68
69 # print results
70
71 # [do game info search]
72 # [...]
73
74 # clean up
75
76 # os.system('rm ./testdata/*.db')
77
Note: See TracBrowser for help on using the browser.