20.01.2013 Views

Kombilo Documentation Release 0.7.4 Ulrich Goertz - Bitbucket

Kombilo Documentation Release 0.7.4 Ulrich Goertz - Bitbucket

Kombilo Documentation Release 0.7.4 Ulrich Goertz - Bitbucket

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER<br />

FOUR<br />

USING THE KOMBILO ENGINE IN YOUR<br />

OWN SCRIPTS<br />

This document describes how to use the <strong>Kombilo</strong> database from your own Python scripts, enabling you to do all kinds<br />

of data mining on your SGF databases.<br />

4.1 Getting started<br />

It is easiest to create some databases using <strong>Kombilo</strong>, and then just use the database files kombilo.d* (or first copy<br />

them somewhere).<br />

Then, a pattern search can be done in a few lines:<br />

# set up the KEngine, load the database files<br />

K = KEngine()<br />

K.gamelist.DBlist.append({ ’sgfpath’: ’.’, ’name’:(’.’, ’kombilo1’),<br />

’data’: None, ’disabled’: 0})<br />

K.loadDBs()<br />

# let us check whether this worked<br />

print K.gamelist.noOfGames(), ’games in database.’<br />

# define a search pattern<br />

p = Pattern(’’’<br />

.......<br />

.......<br />

...X...<br />

....X..<br />

...OX..<br />

...OO..<br />

.......<br />

’’’, ptype=CORNER_NE_PATTERN, sizeX=7, sizeY=7)<br />

# start pattern search<br />

K.patternSearch(p)<br />

# print some information<br />

print K.patternSearchDetails()<br />

For a slightly extended example, see basic_pattern_search. Instead of appending items to<br />

K.gamelist.DBlist manually as above, you can also use the py:meth:GameList.populateDBs method, see e.g.<br />

sgftree.<br />

37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!