Next: Symmetry & transformations, Previous: Tuning, Up: Patterns
The pattern code in GNU Go is fairly straightforward conceptually, but because the matcher consumes a significant part of the time in choosing a move, the code is optimized for speed. Because of this there are implementation details which obscure things slightly.
In GNU Go, the ascii .db files are precompiled into tables (see patterns.h) by a standalone program mkpat.c, and the resulting .c files are compiled and linked into the main GNU Go executable.
Each pattern is compiled to a header, and a sequence of elements,
which are (notionally) checked sequentially at every position and
orientation of the board. These elements are relative to the pattern
'anchor' (or origin). One `X' or `O' stone is (arbitrarily) chosen to
represent the origin of the pattern. (We cannot dictate one or the
other since some patterns contain only one colour or the other.) All
the elements are in co-ordinates relative to this position. So a
pattern matches "at" board position (m,n,o)
if the the pattern anchor
stone is on (m,n)
, and the other elements match the board when the
pattern is transformed by transformation number `o'. (See below for
the details of the transformations, though these should not be
necessary)