Computer Chess Club Archives


Search

Terms

Messages

Subject: Symbolic: On patterns

Author: Steven Edwards

Date: 05:53:45 03/16/04


Working notes on patterns for the Symbolic chessplayer

What is a pattern?  For the purposes of programming Symbolic, an exact
specification is required.

--------

Definition #1: predicate

A predicate is a Lisp function that returns a t/nil value based solely on the
values of its argument(s).  Most predicate names are single words followed by a
question mark.  A predicate is the most primitive form of a pattern and is
really too basic to be considered as a real pattern in the context of writing
Symbolic.  However, they are required for writing recognizer functions which are
used by Symbolic's pattern matcher.

Example predicates:

    (White? arg1) ; Is arg1 a white chessman (or the white color)?
    (Rook? arg1) ; Is arg1 a white rook, a black rook, or a rook piece?

    (defun WhiteRook? (MyMan) (and (White? MyMan) (Rook? MyMan)))

--------

Definition #2: pattern name

Every pattern in Symbolic has a unique name.  It is a simple Lisp identifier.

--------

Definition #3: pattern group

A pattern group is a simple list of pattern identifiers.  A pattern may belong
to more than one group.  Groups are used to support the aggregate activation and
deactivation of pattern eligibility for the matching process.

--------

Definition #4: instance variable

An instance variable is an object associated with a pattern that receives a
value after a successful matching operation.  An instance variable is specified
by a type and an identifier.  The type is usually a chess enumeration type
(square, man, direction, etc.) or a two element list containing a man and a
square.  The type may also be boolean, integer, or a pattern identifier.

--------

Definition #5: instance variable list

An instance variable list is a list of one or more instance variable
specifications.  Each pattern has a single instance variable list.

--------

Definition #6: recognizer function

A recognizer function is a Lisp function, possibly rather complex, that
determines if a particular pattern is a match for any given values for the
instance variables supplied to the recognizer.  A t/nil value (t meaning match)
is returned by a recognizer function.

--------

Definition #7: pattern instance

The result of a successful pattern match is a pattern instance.  It consists of
the pattern identifier and, for each instance variable, the value of the
variable at the time it was submitted to the pattern's recognizer function.
Pattern instances are stored in a dynamic (during search) instance database.
There is a global instance database for the entire search and also local
instance databases, one attached to each node in the search tree.

Some pattern instances are generated immediately via Lisp intrinsic functions
from the attributes of the current position; these are bootstrap instances that
initialize the contents of an instance database.  An example would be the
instances of legal moves for a position.

--------

Definition #7: simple pattern

A simple pattern has an identifier, a list of instance variable specifications,
a recognizer function, and nothing else.

--------

Definition #8: augmented pattern

An augmented pattern contains a simple pattern and an agenda.  The agenda is a
list of pattern actions, each of which is a simple directive, such as posting a
particular datum to some list or activating some pattern group.

--------

Definition #9: pattern matcher

The pattern matcher is a Lisp routine that iteratively prowls the pattern
library and the instance databases.  It calls the recognizer functions for the
augmented patterns and, for each match, the agenda of the augmented pattern is
executed.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.