root/06/libkombilo/testhash.py

Revision 196, 2.1 KB (checked in by ug, 4 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
3import os
4import sys
5import time
6from libkombilo import *
7
8gl = GameList('t1.db', '', '[[PW]] - [[PB]] ([[winner]]), [[filename]], ')
9print gl.size(), 'games in the database'
10
11contList = vectorMNC() # this is a little awkward at the moment ...
12for m in [MoveNC(6,15,'X'), MoveNC(6,13,'O'), MoveNC(4,15,'X')]: contList.push_back(m)
13
14p = 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
37start = time.time()
38gl.search(p, SearchOptions())
39end = time.time()
40print '\n'.join(gl.currentEntriesAsStrings())
41print gl.size(), 'games, ', gl.numHits(), 'hits.'
42for i in range(19):
43    print ' '.join(gl.labels[19*i:19*i+19])
44print 'This search took %.2f seconds.' % (end - start)
45
46print 'Search again without using the hashing algorithm.'
47gl.reset()
48print gl.size(), 'games in the database.'
49so = SearchOptions()
50so.algos = ALGO_MOVELIST | ALGO_FINALPOS
51start = time.time()
52gl.search(p, so)
53end = time.time()
54print gl.size(), 'games, ', gl.numHits(), 'hits.'
55print 'This search took %.2f seconds.' % (end - start)
56
Note: See TracBrowser for help on using the browser.