[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: computer-go: help with a fast pattern matching utility requested



Hello,

mike polyakov <mvp9@xxxxxxxxxxxxxxxxx> wrote:
>Flex/lex is much too big for what I need - ie much 
>slower, and I was hoping for a way to add/subtract 
>patterns from the DFA w/o completely rebuilding it,
>if possible. I considered using GNUgo's matching 
>mechanism - but its too tied to their implementation 
>and it doesn't allow modifying the dfa w/o rebuilding it.

in my program Augos I use strings of the chacters
{a,l,x,o} with the meaning a=outside of the board,
.=empty place on the board, x=computer stone, o=person.
At present I don't use a don't-care character,
but this seems sufficient.

When the program is started, a text file with
strings of the above type is read into a 
quaternary tree. 

At runtime, for each of the 361 points of the 
board, the patterns are built by a
circular process:

      9 10 11 12 
      8  1  2 
      7  0  3
      6  5  4

It's easy to see there are 8 possible routes
to form a pattern. For each of these, the
program seeks in the quaternary tree whether
one of the nodes that is positioned on the
path from the root to the end of the pattern
is labeled a pattern (and therefore
associated with some action code).

Greetings, 
Joachim