| www.delorie.com/gnu/docs/gnugo/gnugo_141.html | search |
![]() Buy GNU books! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Several pattern databases are in the patterns directory. This chapter
primarily discusses the patterns in `patterns.db', `patterns2.db',
and the pattern files `hoshi.db' etc. which are compiled from the SGF
files `hoshi.sgf' (see section 12.16 The Joseki Compiler). There is no essential
difference between these files, except that the ones in `patterns.db' and
`patterns2.db' are hand written. They are concatenated before being
compiled by mkpat into `patterns.c'. The purpose of the separate
file `patterns2.db' is that it is handy to move patterns into a new
directory in the course of organizing them. The patterns in `patterns.db'
are more disorganized, and are slowly being moved to `patterns2.db'.
During the execution of genmove(), the patterns are matched in
`shapes.c' in order to find move reasons.
The same basic pattern format is used by `attack.db', `defense.db', `conn.db', `apats.db' and `dpats.db'. However these patterns are used for different purposes. These databases are discussed in other parts of this documentation. The patterns in `eyes.db' are entirely different and are documented elsewhere (see section 11. Eyes and Half Eyes).
The patterns described in the databases are ascii representations, of the form:
Pattern EB112
?X?.? jump under O.*oo O.... o.... ----- :8,ed,NULL |
Here `O' marks a friendly stone, `X' marks an enemy stone, `.' marks an empty vertex, `*' marks O's next move, `o' marks a square either containing `O' or empty but not `X'. (The symbol `x', which does not appear in this pattern, means `X' or `.'.) Finally `?' Indicates a location where we don't care what is there, except that it cannot be off the edge of the board.
The line of `-''s along the bottom in this example is the edge of the board itself--this is an edge pattern. Corners can also be indicated. Elements are not generated for `?' markers, but they are not completely ignored - see below. The line beginning `:' describes various attributes of the pattern, such as its symmetry and its class. Optionally, a function called a "helper" can be provided to assist the matcher in deciding whether to accept move. Most patterns do not require a helper, and this field is filled with NULL.
The matcher in `matchpat.c' searches the board for places where this
layout appears on the board, and the callback function
shapes_callback() in `shapes.c' registers the appropriate move
reasons.
After the pattern, there is some supplementary information in the format:
:trfno, classification, [values], helper_function |
Here trfno represents the number of transformations of the pattern to consider, usually `8' (no symmetry, for historical reasons), or one of `|', `\', `/', `-', `+', `X', where the line represents the axis of symmetry. (E.g. `|' means symmetrical about a vertical axis.)
The above pattern could equally well be written on the left edge:
|oOO? |...X |..*? |..o. |..o? :8,ed,NULL |
The program mkpat is capable of parsing patterns written this
way, or for that matter, on the top or right edges, or in any
of the four corners. As a matter of convention all the edge patterns
in `patterns.db' are written on the bottom edge or in the lower left
corners. In the `patterns/' directory there is a program called
transpat which can rotate or otherwise transpose patterns.
This program is not built by default--if you think you need it,
make transpat in the `patterns/' directory and
consult the usage remarks at the beginning of `patterns/transpat.c'.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |