root/06/libkombilo/testhash.py

Revision 196, 2.1 kB (checked in by ug, 2 years ago)

Changed GameList so as to keep the db connection open all the time.
Added resetFormat, getSGF methods. Slight changes to how the format
string works. Some minor bugs fixed.

  • Property svn:executable set to *
Line 
1 #! /usr/bin/env python2.4
2
3 import os
4 import sys
5 import time
6 from libkombilo import *
7
8 gl = GameList('t1.db', '', '[[PW]] - [[PB]] ([[winner]]), [[filename]], ')
9 print gl.size(), 'games in the database'
10
11 contList = vectorMNC() # this is a little awkward at the moment ...
12 for m in [MoveNC(6,15,'X'), MoveNC(6,13,'O'), MoveNC(4,15,'X')]: contList.push_back(m)
13
14 p = Pattern(FULLBOARD_PATTERN, 19, 19, 19,
15             '...................' + \
16             '..O.O........OX....' + \
17             '..XO......X.OXX.XX.' + \
18             '..X,.OOXXX..OOOX.O.' + \
19             '...X.OXOOXOO..OX...' + \
20             '....XOXXOXXOOXXOO..' + \
21             '..OX.XXXOOOXO.O.O..' + \
22             '.OXX..XOX..XO.X.XO.' + \
23             '..O.......X.....XO.' + \
24             '.O.,X....,.....XOO.' + \
25             '...............X...' + \
26             '...X............X..' + \
27             '..O................' + \
28             '...................' + \
29             '........O.O........' + \
30             '...O.....,.....X...' + \
31             '........X.O.X......' + \
32             '...................' + \
33             '...................', contList)
34
35 # p = Pattern(FULLBOARD_PATTERN, 19, 19, 19, "..O.O....X...XXXXX.OOXO....OXO.XXOOOXOXXXXOO.OOXO.OXO..O..X.X..OOX,X.XO.O.....XOOOXOXX..XO......X.XOXXX..XXXO........XOX..XXOOXO.OOO.....OOXOXOO.O...XX...X..OXXOO.XOX........O..OX.,..X..X.....X...OX...X..........O....XXXO...XO...X...OOOXOOXX...X....O..OX.O..OX..........OXX....OX..OO..O.OOOOX..O.OX..XX..OOXXXOX.XOOX..X....XXXXXOX...OX.......X.O.XO.............")
36
37 start = time.time()
38 gl.search(p, SearchOptions())
39 end = time.time()
40 print '\n'.join(gl.currentEntriesAsStrings())
41 print gl.size(), 'games, ', gl.numHits(), 'hits.'
42 for i in range(19):
43     print ' '.join(gl.labels[19*i:19*i+19])
44 print 'This search took %.2f seconds.' % (end - start)
45
46 print 'Search again without using the hashing algorithm.'
47 gl.reset()
48 print gl.size(), 'games in the database.'
49 so = SearchOptions()
50 so.algos = ALGO_MOVELIST | ALGO_FINALPOS
51 start = time.time()
52 gl.search(p, so)
53 end = time.time()
54 print gl.size(), 'games, ', gl.numHits(), 'hits.'
55 print 'This search took %.2f seconds.' % (end - start)
56
Note: See TracBrowser for help on using the browser.