Using Patterns and Plans in Chess
Using Patterns and Plans in Chess
R e c o m m e n d e d by H a n s Berliner
ABSTRACT
The purpose of this research is to investigate the extent to which knowledge can replace and support
search in selecting a chess move and to delineate the issues involved. This has been carried out by
constructing a program, P A R A D I S E (PAttern Recognition Applied to Directing SEarch), which
finds the best move in tactically sharp middle game positions from the games of chess masters. It
encodes a large body of knowledge in the form of production rules. The actions of the rules post
concepts in the data base while the conditions match patterns in the chess position and data base. The
program uses the knowledge base to discover plans during static analysis and to guide a small tree
search which con~ms that a particular plan is best. The search is "small" in the sense that the size of
the search tree is of the same order of magnitude as a human master's search tree (tens and hundreds
of nodes, not thousands to hundreds of thousands as in many computer chess programs).
Once a plan is formulated, it guides the tree search for several ply and expensive static analyses
(needed to analyze a new position) are done infrequently. P A R A D I S E avoids placing a depth limit
on the search (or any other artificial effort limit). By using a global view of the search tree,
information gathered during the search, and the analysis provided by the knowledge base, the
program produces enough terminations to force convergence of the search. P A R A D I S E has found
combinations as deep as 19 ply.
1. I n t r o d u c t i o n
O n e of the central concerns of artificial intelligence is expressing k n o w l e d g e
and reasoning with it. Chess has b e e n one of the m o s t p o p u l a r d o m a i n s for A I
research, yet brute force searching p r o g r a m s with little chess k n o w l e d g e play
b e t t e r chess than p r o g r a m s with m o r e chess knowledge. T h e r e is still m u c h to
be learned a b o u t expressing and using the kind of k n o w l e d g e involved in
playing chess. CHESS 4.7 is p r o b a b l y the best chess p r o g r a m , and its authors
m a k e the following c o m m e n t s in [12]:
But why is the program so devoid of chess knowledge? It is not because we are deliberately
trading it for speed of execution .... It is not quite true to say that we don't know how to feed
additional knowledge to the program .... Our problem is that the programming tools we are
presently using are not adequate to the task. Too much work is needed to encode the sizable
body of knowledge needed to significantly improve the quality of play.
Artificial Intelligence 14 (1980), 165--203
Copyright © 1980 by North-Holland Publishing Company
166 D. WlLKINS
Human masters, whose play is still much better than the best programs, appear
to use a knowledge intensive approach to chess (see [2]). They seem to have a
huge number of stored 'patterns,' and analyzing a position involves matching
these patterns to suggest plans for attack or defense. This analysis is verified
and possibly corrected by a small search of the game tree. Unlike the searches
conducted by most programs, the human master's search usually has specific
goals to accomplish and returns useful information which affects the analysis of
other lines. The purpose of this research is to investigate the issues involved in
expressing and using pattern-oriented knowledge to analyze a position, to
provide direction for the search, and to communicate useful results from the
search.
To reduce the amount of knowledge that must be encapsulated, the domain
of the program has been limited to tactically sharp middle game positions. The
phrase 'tactically sharp' is meant to imply that success can be judged by the
gain of a material rather than a positional advantage. The complexity of the
middle game requires extensive search, providing a good testing ground for
attempts to replace search with knowledge and to use knowledge to guide the
search and communicate discoveries from one part of the tree to another.
Since, in our chosen domain, the attacking side can generally win material
with correct play, the program uses different models for the offensive and
defensive players during its search of the game tree. The offensive player uses a
large amount of knowledge, suggests many esoteric attacks, and invests much
effort in making sure a plan is likely to work before suggesting it. The defensive
player uses much less knowledge and effort, tries any defense that might
possibly work, and tries only obvious counter attacks. Trying every reasonable
defense enables the offense to satisfy itself that a line really does win, The size
of the tree is kept small because the offensive player finds the best move
immediately in most cases.
For a knowledge based program to achieve master level performance, it
seems necessary that the knowledge base be amenable to modifications and
additions. PARADISE provides for easy modification of and addition to its
knowledge base (without adversely affecting program performance), thus al-
lowing the knowledge to be built up incrementally and tuned to eliminate
errors. This is accomplished by having the knowledge base composed of largely
independent production rules which are written in a straightforward Produc-
tion-Language [13].
The goal is to build an expert knowledge base and to reason with it to
discover plans and verify them with a small tree search. As long as this goal is
reached, the amount of execution time used is not important. It is a design
decision to sacrifice efficient execution in order to use knowledge whenever
reasonable. When a desired level of performance is reached, the program could
be speeded up considerably by switching to a more efficient representation at
the cost of transparency and ease of modification.
USING PATrERNS AND PLANS IN CHESS 167
1. Q-R5ch NxQ
2. PxPch K-N3
~llll,. .... ~IIA. ~filll,,HW, ff.~."
~'~;.-'ff~ " ~ vz 3. B-B2ch K-N4
4. R-B5ch K-N3
5. R-B6ch K-N4
6. R-N6ch K-R5
7. R-K4ch N-B5
8. R x N c h K-R4
9. P--N3 any
10. R-R4 mate
2. Overview of PARADISE
((DMP1)
(NEVER (EXISTS(SQ) (PATFERNMOBILDMP1 SQ)))
(NEVER(EXISTS(P1) (PATTERNENPRISP1 DMP1)))
(ACTION A'VrACK ((OTHER-COLOR DMP1) (LOCATION DMP1)) (THREAT (WIN DMP1))
(LIKELY0)))
fourth line constitutes the action. The first line specifies one variable that must
be instantiated. Because of its name, the variable must be instantiated to a
defensive piece that is not a pawn. The next two lines in the production access
two more primitive patterns that have already been matched, MOBIL and
ENPRIS. The MOBIL pattern matches each legal move that can be made
without losing the moving piece. If there are no squares which match MOBIL
when DMP1 is the first argument, then DMP1 is trapped. Only in this case will
there be any possible instantiations for DMP1 after the second line in Fig. 1 is
matched. The third line prevents the pattern from matching if the trapped
piece is a ready en prise. The idea is that in this case DMP1 should be captured
outright rather than attacked. Thus this production matches only trapped
pieces which are not en prise.
In Fig. 1, the action of the production rule posts an ATI~ACK concept. This
concept gives instantiations for two variables and tells the system that the
opposite color of DMP1 would do well to attack the square which is DMPI's
location. In addition one reason is given for suggesting this concept. This
reason consists of attributes describing the threat of the concept and how likely
it is to succeed. Concepts are discussed in more detail later in this paper. The
more primitive patterns (such as MOBIL) and the language in which produc-
tions are written are described in detail in [13].
To offset the expense of searching for patterns in the position, problems
must be solved with small search trees. In fact, PARADlSE can be viewed as
shifting some of its search from the usual chess game tree to the problem of
matching patterns. PARAmSE shows that its pattern-oriented knowledge base
can be used in a variety of ways to significantly reduce the part of the game
tree which needs to be searched. This reduction is large enough that a high
level of expertise can be obtained using a large but still reasonable amount of
resources. This reduction is also large enough that PARADISEavoids placing a
depth limit (or any other artificial effort limit) on its search. The various ways
in which the knowledge base is used are briefly mentioned below.
Calculating primitives. PARADISE'S knowledge base contains about twenty
patterns (productions without actions) which are primitives used to describe
a chess position. These patterns are matched once for each position. They
range from matching legal moves to matching patterns like MOBIL and
ENPRIS. The primitives are relatively complex and calculating them is
expensive.
USING PATrERNS AND PLANS IN CHESS 169
Executing plans. The execution of a plan during the tree search requires
using the knowledge base to solve goals specified in the plan. This use of the
knowledge base could be viewed as a static analysis where the system's
attention is focused on a particular goal or aspect of the position. Such a
focused analysis can be done at a fraction of the cost of a full analysis which
examines all aspects of the position.
In this way PARADISEconstructs new plans using the information gained from
searching an unsuccessful plan.
Answering questions. The search often requests certain kinds of information
about the current position. The knowledge base is used to provide such
information. The most frequent requests ask if the position is quiescent and
if there are any obviously winning moves in the position.
The above list describes eight general functions the knowledge base performs
for PARADISE.This paper explains how plans are produced and executed. The
productions, the static analysis, the tree search, and mechanisms for com-
municating information from one part of the tree to another are discussed in
[13].
N NxNxN
2N;
N N NN
FIG. 2. White to move.
In the above position, most computer chess programs would search the game
tree as deep as their effort limit allowed and decide to play K-K3 which
centralizes the king. They cannot search deep enough to discover that white
can win since white's advantage would take more than 20 ply to show up in
most evaluation functions used by computer programs. The point is that the
solver of the above problem uses conceptual reasoning to solve it, and the
concepts must be higher level than the legal moves in a chess position. A
human master would recognize the following features (among others) in the
above position: the black king must stay near his KB1 to prevent white's king
bishop pawn from queening, the pawns form a blockade which the kings can't
penetrate, and the kings can bypass this blockade only on the queen rook file.
USING PATrERNS AND PLANS IN CHESS 171
Such an action effectively adds to the plausibility score for some possible
answer. This presupposes that any one writer of all the rules knows every
possible solution since such rules will never create a diagnosis that has not been
mentioned in the action part of some rule.
Using actions similar to those used in MYCINrules would be similar to a chess
system where the action part of each rule was to add to the plausibility score of
either
(1) one or more of the legal moves in the position, or
(2) some prespecified object which could lead (through other rules) to
recommending a legal move.
Such an approach is not satisfactory for the type of chess reasoning needed in
the above problems. Concepts at a higher level than legal moves must be used
in this reasoning, and objects cannot be prespecified (e.g., the extent of blockade
must be created dynamically). Thus, PARADISEmust reason by linking concepts
to create plans instead of filling in prespecified slots.
In most current expert production systems (such as MYCIN), the action parts
of the rules are in some sense part of the solution or a pointer to something
which can produce a solution. In chess the system must discover lines of play
that were not implicit in the knowledge base. Thus the word 'create' is used.
MYClNhas a small solution set (120 organisms) and can mention each solution in
its rules, while a chess program must discover an enormous number of lines
using a set of productions which is much smaller in size (by an order of
magnitude or more) than the number of plans it must recognize. This can be
seen by looking at the actual production rules: MYCIN'S actions mention the
names of objects while PARADISE'S actions involve many variables whose
instantiation is not determined until execution of the action.
172 D. WILKINS
5. Plato
The goal of the static analysis process in PARADISEis to produce plans. Plans
seem to play an important role in the problem solving process of move
174 D. W I L K I N S
selection for good human chess players. Alexander Kotov in his book Think
Like a Grandmaster Kotov [7, p. 148] writes:
... it is better to follow out a plan consistently e v e n if it isn't the best o n e t h a n to play w i t h o u t a
plan at all. T h e w o r s t thing is to w a n d e r a b o u t aimlessly.
(P SQ) matches when the defense has moved the piece P to the square SQ.
(NIL SQ) matches when the defense has moved any piece to SQ.
(P NIL) matches when the defense has moved P (to any square).
(ANYBUT P) matches when the defense has moved some piece other than
P.
NIL matches any defensive move.
The plan for an offensive move can be one of two things: a particular move or
USING PA'Iq'ERNS AND PLANS IN CHESS 175
a goal. A particular move is simply the name of a piece and a square. Such a
plan causes PARADISEto immediately make that move with no analysis of the
position other than checking that the move is legal. A goal is simply the name
of a KS followed by an instantiation for each argument of the KS. When
executing a goal, PARADISEwill post a concept corresponding to the KS in the
data base by using the given instantiations and the attribute lists of this plan as
a whole. The KS will then be executed for this concept. Any plan produced by
this execution will replace the goal in the original plan and this modified plan
will be used. This process expands and ellaborates plans. If executing the KS
does not produce a plan then the original plan has failed.
~/~ ~ ~ I
(((WN N5)
(((BN N4) (SAFEMOVE WR Q7)
(((BK NIL) (SAFECAPTUREWR BR))
((ANYBUT BK) (SAFECAPTUREWR BK))))
((BN N4) (CHECKMOVE WR Q7) (BK NIL) (SAFECAPTURE
WR BQ) )))
((THREAT (PLUS (EXCHVAL WN N5) (FORK WR BK BR)))
(LIKELY 0))
((THREAT (PLUS (EXCHVALWN N5) (EXCH WR BQ)))
'
(LIKELY 0)))
A plan produced by PARADISE
FIG. 3. White to move.
Fig. 3 shows a problem and one of the plans PARADISE'S static analysis
produces for it. ('WN' means white knight, 'N5' means the square N5, etc.)The
internal representation of PARADISEhas not been printed unambiguously since
the term 'WR' does not specify which white rook. However, it should be
obvious to which piece the names refer. The last two lines of the plan are
attribute lists. The first five lines are the Plan-Language expression for the plan
which can be read as follows:
Play N-N5. If black captures the knight with his knight, attempt to safely
move the rook on QI to Q7. Then, if black moves his king anywhere try to
safely capture the black rook on R7, and if black moves any piece other than
his king, try to safely capture the king with the rook. A second alternative after
black captures the knight is to attempt to safely move the rook on QI to Q7
with check. Then, if black moves his king anywhere try to safely capture the
black queen with the rook.
as the continuation of the original plan, causing the system to play R - Q 7 with
no further analysis. If for some reason R--Q7 was not safe then the SAFE-
MOVE KS will try to make Q7 safe for the rook (by posting a SAFE concept).
If some plan is found, the original plan will be 'expanded' by replacing the
SAFEMOVE goal with the newly found plan. In general, the newly found plan
will contain (SAFEMOVE W R QT) though it may come after a sacrificial
decoy or some other tactic. If posting the SAFE concept does not produce a
plan, then the SAFEMOVE goal has failed, and the alternative CHECK-
MOVE goal will be tried. If it also fails, a complete analysis of the position
must be done. If black had answered N-N5 with a king move, it would not
match the template (BN N4) and a complete analysis of the position would be
undertaken without attempting to make Q7 safe for the rook.
By use of conditionals, a plan can handle a number of possible situations
which may arise. The most important feature of the Plan-Language is that
offensive plans are expressed in terms of the KSs. This has many advantages.
Relevant productions are immediately and directly accessed when a new
position is reached. The system has one set of abstract concepts it understands
(the KSs) and does not need to use a different language for plans and static
analysis. The system has been designed to make the writing of productions and
thus the forming of KSs reasonable to do. Thus the range of plans that can be
expressed is not fixed by the Plan-Language. By forming new KSs, the range of
expressible plans may be increased without any new coding (in the search
routines or anywhere else) to understand the new plans. This is important since
the usefulness of the knowledge base is limited by its ability to communicate
what it knows ~(e.g., through plans).
Given a number of plans to execute, the tree search must make decisions
about which plan to search first, when to forsake one plan and try another,
when to be satisfied with the results of a search, and other such things. To
make such decisions, it must have information about what a plan expects to
gain and why. Such information was available to the productions which
matched to produce the plan and must be communicated in the attribute lists of
the plan so as to provide many different types of access to this knowledge.
Unlike most search-based chess programs, PARADISEmust use its information
about a plan at other nodes in the tree since it executes a plan without
analyzing the newly created positions.
To use the information about plans in an effective manner, PARAI)ISEdivides
a plan's effects into four different categories which are kept separately (i.e.,
their values are not combined in any way). These four categories are:
T H R E A T which describes what a plan threatens to actively win,
SAVE which describes counterthreats of the opponent a plan actively
prevents,
LOSS which describes counterthreats of the opponent not defended against
and functions the first piece to move in a plan will give up by abandoning its
USING PATrERNS AND PLANS IN CHESS 177
current location (thus providing new threats for the opponent), and
LIKELY which describes the likelihood that a plan will succeed.
These four categories have emerged during the development of rARADISE.
Experience seems to indicate the system must have at least these four dimen-
sions along which to evaluate plans in order to adequately guide the tree
search.
Since the values for these categories must evaluate correctly at different
nodes in the tree, they cannot be integers. Instead they (except for LIKELY)
are expressions in the Threat-Language [13] which can describe threats in a
sophisticated manner. These expressions are evaluated in the context of the
current position and may return different values for different positions. The
value of LIKELY is an integer. This integer represents the number of unforced
moves the defense has before the offense can accomplish its plan. The most
likely plans to succeed have a LIKELY of zero (every move is forcing). Both
attribute lists in Fig. 3 have a likelihood of zero.
6. Creating Plans
A detailed description of the static analysis process in PARADISEis given in [13].
The concepts and KSs used to produce the plan in Fig. 3 are briefly described
here. The system begins by posting a T H R E A T concept, the T H R E A T KS
having productions which look for threats. Two different productions in
T H R E A T post MOVE concepts for moving the white rook to Q7. (One
recognizes the skewer of the black king to the rook, and the other recognizes
the simultaneous attack on the king and queen where any king move leaves the
queen open to capture with check.) After executing the T H R E A T and
ATTACK KSs, the system executes the MOVE KS on the 50 MOVE concepts
which have been posted by productions. In addition to Q7, there are MOVE
goals for moving the rook to QB7, K7, KB8, Q6, QB6, QN6, and QR6 as well
as many goals for moving other white pieces. A production in the MOVE KS,
that recognizes that the proposed move is unsafe, matches for the white rook to
Q7 MOVE goal. This production posts a SAFE concept for making Q7 safe for
the white rook. After the MOVE KS is finished, 7 SAFE goals have ac-
cumulated. While executing the SAFE KS for the white rook to Q7 goal, one
production notices that the black knight blocks the white queen's protection of
Q7, This production posts a DECOY goal in order to decoy the black knight so
that the queen can support the white rook on Q7. The DECOY KS is executed
on the 7 DECOY goals which have been produced, and one production posts a
FORCE goal suggesting N-N5 as a move to decoy black's knight. It is up to the
FORCE KS to decide if N-N5 is forcing enough to provoke a move by the
black knight. There are 9 FORCE goals in all and the production which finds
N-N5 forcing posts an INITIAL-PLAN concept which is exactly like the plan
shown in Fig. 3.
178 D. WILKINS
ply of the plan as ((WN NS) (BN N4) (SAFEMOVE WR Q7)). Suppose this
had been expressed as ((WN NS) NIL (WR Q7)). Playing R-Q7 after N x N is
reasonable but if black moves his king instead, playing R--Q7 will lead the
search down a blind alley. Thus, (WR Q7) is too specific and does not express
white's purpose. This problem can be cured by a more specific description of
black's reply (e.g., (BN N4) instead of NIL) since the template for black's move
will not match if black moves his king. In actual fact, PARADISEdoes not know
for sure that R-Q7 will be safe after N-N5 and N x N (although in this
particular position it is). To avoid mistakenly playing R-Q7 when it is not safe,
PARADISE USeS a SAFEMOVE goal to more accurately express the purpose of
the plan. For example, the plan could be ((WN N5) NIL (SAFEMOVE WR
Q7)). If black answers N-N5 with N x N then the SAFEMOVE goal is
reasonable and quickly produces R-Q7 as the move to play after verifying its
safety. If black answers with a king move then the SAFEMOVE goal is not
what white wants to do, but little is lost since R-Q7 is not safe and the line will
be rejected without searching. However, if likely plans had existed for making
Q7 safe, the search may still have been led astray. For this reason, PARADISE
USeS (BN N4) as the template in this plan. The purpose of N-N5 is to decoy the
black knight to his KN4 and this template most accurately expresses this
purpose.
Now let us consider the following more general plan: ((WN N5) NIL
(SAFELY-ATrACK BK)). If black answers with N x N then the SAFELY-
ATFACK KS should generate R-Q7 as a safe attack on the black king. If,
instead, black moves his king then this KS should generate a check by the
white queen or knight which would also be reasonable. Thus this plan produces
reasonable moves for every black reply without ever causing a re-analysis of
the new position. This would be a good plan if PARADISE knew (from its
patterns) that it could get the black king in trouble after any reply. However, it
only knows of the skewer of the black king to the rook, the threat of capturing
the queen with check, and the fact that the white knight threatens the black
king, rook, and knight from N5. It is accidental that the SAFELY-ATrACK
goal works after black retreats his king. In the general case, such a goal would
produce many worthless checks that would mislead the search. Thus this plan is
too general to describe white's actual purpose.
It is very important to get the correct level of detail in a plan. The plan
should handle as many replies as possible without causing a re-analysis, but it
should avoid suggesting poor moves. The templates for describing defensive
moves in the Plan-Language and the various KSs have been developed to allow
PARADISE'S plans to accurately express their purpose. The results have been
quite satisfying: the productions in PARADISE now create plans which rarely
suggest poor moves but which can still be used for as many ply as a human
might use his original idea.
180 D. WILKINS
(PLY 1)
BESTPLAN:
(((WQ R7) (BK R2) (CHECKMOVE WR R5) (BK NIL)
(ATTACKP BK))
((HINT 1) (THREAT (PLUS (WIN BK) (EXCHVAL WQ R7)))
(LIKELY 1)))
(PLY 6)
INITIAL DEFENSIVE MOVES:
((BR R6) (BB Q2) (BB N2) (BR B4) (BR 133)(BR B1))
FIG. 5.
plan in this position. This replaces (ATFACKP BK) in the current plan, thus
elaborating it. After playing N-N6, the position in Fig. 5 is reached.
Productions which know about defending against R-R8 suggest the 6 black
moves in Fig. 5. Black plays B × P first in an effort to save the bishop from the
ensuing skewer. At this point the plan branches. Since both branches begin with a
null template, they both match any black move at ply 6. Thus P~ADISE has two
plans at ply 7: (SAFEMOVE WR R8) and (SAFEMOVE WN K7). Before
executing a plan for the offense, PA~mSE executes the QUIESCENCE KS which
looks for obviously winning moves. (This was done at plys 3 and 5 also, but did not
suggest any moves.) Here R-R8 is suggested by the QUIESCENCE KS which
causes the (SAFEMOVE WR R8) plan to be executed immediately. PARADXSE
plays R-RS, finds that black is mated, and returns to ply 6 knowing that black's
B × P leads to mate. All this has been accomplished without a static analysis; the
original plan has guided the search.
At ply 6, black uses KSs to refute the mating line. This involves analysis of
the information produced by the previous search. No new moves are found
since all reasonable defenses have already been suggested. PARADISE has a
causality facility (see [14]) which determines the possible effects a move might
have on a line of play. Using ipJormation generated during the search of the
mating line, the causality facility looks for effects a proposed move might have
(such as blocking a square which a sliding piece moved over, vacating an escape
square for the king, protecting a piece which was attacked, etc.). The causality
facility recognizes that neither B--Q2 nor B-N2 can affect the mating line found
for B × P so they are rejected without searching.
Black plays R-B4 next, the causality facility having recognized that this
move opens a flight square for the black king. Again I'ARADXSEhas both
(SAFEMOVE WR RS) and (SAFEMOVE WN K7) as plans at ply 7. Both
SAFEMOVE goals would succeed, but R-R8 has a higher recommendation
and is played first. Black plays his only legal move at ply 8, K-B2.
The original plan no longer provides suggestions at ply 9. PARADISEmust now
look for better alternatives or do an expensive static analysis to suggest a new
182 D. WILKINS
plan. Before trying either of these, the program executes the QUIESCENCE
KS in an attempt to find an obviously winning move. R-KB8 is suggested and
PARADISE immediately plays this move without doing a static analysis. This is
mate so PARADISEreturns to ply 6 to look for other defenses,
Both R-B3 and R-B1 are tried and both are quickly refuted by playing
R - R 8 from the SAFEMOVE goal of the original plan, K-B2, and R-KB8 from
the QUIESCENCE KS. The search then returns to ply 2 and tries K-B1 in
answer to Q x Pch. The template in the original plan does not match K-B1 so
there is no plan at ply 3. However, the QUIESCENCE KS quickly suggests
Q-R8 and PARADISEreturns from the search convinced that Q x Pch will mate.
This result shows that Q x Pch is best, so no other best-first searches are
initiated.
PARADISE'S plans are not always so accurate but space prevents presentation
of a longer search. The above analysis uses about 130 seconds of cpu time on
a DEC KL-10. It goes to a depth of 9 ply while creating only 21 nodes in the
tree. Because of the guidance provided by the original plan, no static analysis
was performed except on the original position. By comparison, the TECH2
program (an improved version of TECH [6]) at a depth setting of 6 discovers
that it can win material with O x Pch although the horizon effect hides the mate
from it. For this analysis, TECH2 uses 210 seconds of cpu time on a KL-10 and
creates 439,459 nodes by making legal moves (as well as making 544,768 illegal
moves which are retracted).
a b c d e # g h
FIG. 5.1. W h i t e to m o v e .
USING PA'I'TERNS AND PLANS IN CHESS 183
( T O P L E V E L ( V A L U E . 0))
PLY 1 ( E X P E C T . 320)
B E S T P L A N : (WB H7) (BK F8) (WO A3))
N E W B O A R D : (E4 WB H7)
The value of the initial position is 0. (White is trying to achieve a positive score.) The best plan
specifies moving the WB to H7 and if black replies by moving his king to F8, the WQ-A3 is
played. The reasoning behind the suggestion of this plan is fairly specific. PARADISEknows that
after B-H7 black must move his king either to H8 where white has a discovered check, or to F8
where white can deliver a second check to which black's king cannot move in reply. The
expectation of this plan (after 'EXPECT'), which is calculated from the attribute lists of the plan,
is 320 (90 is the value of a queen, so 320 threatens mate). Wherever the word 'NEWBOARD'
occurs, PARADISEconstructs a new hoard position by playing a legal move.
PARADISEknows (BR D6) will not help; CAPSsearches it after refuting (BR E7).
.J
(CHECKMOVE WR H8) goal in the current plan. A range is returned as the value, but both the
top and bottom of the range are 1300 (the value for mate) since the value has been exactly
determined.
L NLe; e
IN N N,kN,
tSN2 N; N
IN N NaN
jf
J S
/
/ jS
,o ~ ~ ~ ~ ~ff~--
~~o~_~, ~ .~ ~ '~,,~.~
,p
USING PATIERNS AND PLANS IN CHESS 189
(PLY: 8 ) D E F M O V E S : ( )
(PLY: 6) R E F U T E : ((WK G2))
(PLY: 6) D E F M O V E S : ((BQ A2) (BK G8))
C A U S A L I T Y : (BQ A2) LINE: (D8 B R D3) NO
C A U S A L I T Y : (BK G8) LINE: (G7 BP GS) NO
(PLY: 6 ) D E F M O V E S : ( )
The search backs up to ply 5 and tries the next plan suggested by the static analysis. This plan
has a LIKELY of 1 and the result already achieved is so successful that PARADISErejects the
unlikely plan without searching.
The search backs up to ply 3. There are no more plans to execute here, but a static analysis has
not yet been done so the program makes a note of this. The top of the value range is changed to
320 to reflect the possibilityof achievingthe original expectation by doing a static analysis to find
plans.
N U L L P L A N ( V A L U E . 0) (STATIC-ANALYSIS 14.2 S E C O N D S ) (2
PLANS)
PLY 3 B E S T P L A N : ((WB D3))
( N E W E X P E C T . 320)
N E W B O A R D : (H7 WB D3)
The defense tries K-H8 at ply 2 and the original plan does not match this move so a static
analysis is undertaken. Again PARADISEfinds the right idea immediately.To compare, CAPSdid
not have the necessary knowledgeand tried 3 other moves first, generating 80 nodes to disprove
them, before stumbling onto B-D3.
(PLY: 4) D E F M O V E S : ((BK G8))
N E W B O A R D : (H8 B K G8)
( V A L U E . 0) T R Y O B V I O U S L Y W I N N I N G M O V E
PLY 5 B E S T P L A N : ((WB E2)).
( N E W E X P E C T . 90)
N E W B O A R D : (D3 WB E2)
(PLY: 6 ) D E F M O V E S : ( )
(VALUE. 99)TRY QUIESCENCE SEARCH
(QUIESCENCE VALUE (99.99))
(EXIT O F F E N S E ( V A L U E 9 9 . 9 9 ) )
(PLY: 6) D E F M O V E S : ( ) PLY 5 L A S T P L A N
(EXIT O F F E N S E ( V A L U E 9 9 . 320))
(PLY 4) R E F U T E : ((WB E2)) (PLY: 4) D E F M O V E S : ( )
PLY 3 B E S T P L A N : ((WB E4))
( N E W E X P E C T . 10)
TERMINATE: FORWARD PRUNE
(EXIT O F F E N S E ( V A L U E 9 9 . 320))
The search backs up to ply 3 and the offense tries B-E4 which has been suggested by the static
analysis. Its expectation is 10 and B-D3 has already achieved 99 so a forward prune occurs.
(PLY 2) R E F U T E : ((WB O3))
(PLY: 2 ) D E F M O V E S : ( )
PLY 1 B E S T P L A N : ((WQ A3) NIL (CHECKMOVEWB n7))
no unlikelys after success: quit
The search returns to the top level to try the next plan but it is terminated because it has a
LIKELY of 1 and the search is over. CAM invests much effort at this point searching other
offensive moves.
B E S T M O V E : (E4 WB H7) V A L U E : (59. 320)
PRINCIPAL VARIATION:
1 (E4 WB H7) ((38 BK F8)
2 ((33 W Q A3) (E8 B R E7)
USING PATrERNS AND PLANS IN CHESS 191
Many things should be noticed in this example. The plans do an excellent job
of guiding the search: only two static analyses are done in the entire search.
The plans are so accurately specified by the analysis that they never once lead
the search off the correct line. White's play in the search is error-free. The
causality facility makes good use of information returned from the search.
Many black moves which would otherwise have been searched are eliminated
in this manner. The range values accurately express the potential of each node
so that the system does not have to waste effort determining the 'true' values.
The best first search strategy plays a minor role in this example.
On this problem, CAPSgenerated a tree of 489 nodes in 115 seconds to obtain
a principal variation of B-R7ch, K-B1, Q-R3ch, R-K2, B-Q3, Q xRch,
B x Q, R-Q8. This is slightly inaccurate since there is a mate in one for white
at the end of this variation which CAPS'Squiescence analysis did not recognize,
but it is clear that CAPS understands the problem and its solution. PA~DISE
generates only 36 nodes to CAPS'S 489 for the following three reasons (pri-
marily):
--PARADISE has more knowledge available during static analysis and can
accurately analyze a position and produce good plans. CAPS generates many
nodes by not playing the correct offensive move first on some occasions.
--PARAOXS~. returns more useful information from its search and can there-
fore use its causality facility to eliminate moves that CAPSsearches.
--PARADISE has a best-first search strategy while CAPSis committed to finding
the 'true' value (within alpha-beta) of each node it searches. This enables
PARADlSE to terminate as soon as some information is discovered without
having to look for better alternatives.
This comparison shows the advances PARADISEhas made in the use of know-
ledge. It is not meant to belittle CAPSwhich pioneered some of the techniques
192 D. WILKINS
basic to this approach. In fact, CAPS is the only program with which a
comparison is appropriate. For example, on this problem CHESS4.4 (running on
a CDC-6400) produces a tree with 30,246 nodes in 95 seconds of cpu time
without finding the solution (which is too deep for it). Looking at the details of
such a tree would not be helpful.
of the program, these were tried first. Adding new knowledge during program
development would (hopefully) not adversely affect performance on earlier
problems, but this had to be confirmed. For example, productions added to the
knowledge base to solve the last 5 developmental problems might produce so
many suggestions in the first 5 problems that the search would become
untractable in those problems. The testing proved that the new knowledge had
no adverse effects. All 21 problems fell into category 1; thus the same version
of the program solves them all. In every case, the analysis is either the same as
or sharper than that produced by developmental versions of the program. This
result provides strong evidence that the knowledge base is easily modifiable. If
productions are written carefully and intelligently (a skill the author developed
while writing productions for the developmental set), they do not appear to
adversely affect the system's performance on positions unrelated to the new
productions. This is an essential quality for a modifiable knowledge base.
Table 1 shows what percentage of these problems can be solved by PAgADISE,
PARADISE'2, CAPS (Berliner [1]), TECH (Gillogly [6]), CHESS 4.4 (Slate [12])
running on a CDC 6400, and a human player rated as class A (Berliner [1]).
PARADISE was limited to forty-five minutes of cpu time per problem while the
other programs were limited to five minutes.
PAgADISE already exhibits more generality in this domain than programs like
a'Ecrl and CAPS. PAgADISE-2outperforms all the programs and the human. This
shows that these problems do not push the limits of the expressibility of the
production language nor the ability of the program to control the tree search.
PARADISE does well on Group III because seven of those twenty problems are
in the twenty-one problems on which PARADlSEwas developed.
There are twenty problems solved by PARADISE-2but not by PARADISE,but
only thirteen productions were written to solve them. In two instances, an
already existing production was modified. In five instances the same production
solved two different category three problems. This is a strong indication that
the productions being written are fairly general and not tailored to the specific
problem. These results indicate that the generality of PARADISEis reasonable
and that the modifiability of the knowledge base is excellent. There are three
problems not solved by PARADISE-2which are discussed in the next section.
TABLE 1. Percentage of problems solved by various chess players
PARADISE uses more cpu time and produces trees with considerably fewer
nodes than the other programs. The example search in Section 8 is a problem
from Group III, and tree sizes of 21 nodes for PARADISEand 439, 459 for TECH-2
are fairly typical. Table 2 compares the average tree size (in number of nodes)
for PARADISE-2, CAPS and CHESS4.4 on the problems they solved in these 100.
PARADISE attempts to use knowledge whenever possible in order to produce
trees of the same order of magnitude as those produced by human masters.
Table 2 shows that this has been accomplished for the most part. CAPS uses a
lot of knowledge but invests only about one-fifth of a second per node
calculating. CAPS relies on the search to correct mistakes made by inadequate
knowledge and this results in trees one order of magnitude larger than those
produced by PARADISE. CHESS 4.4 has little chess knowledge and relies almost
entirely on search to discriminate between moves. It generates trees that are
three orders of magnitude larger than those generated by PARADISE. The two
knowledge-oriented programs (CAPS and PARADISE)grOW larger trees for the
deeper combinations (Groups IV and V), just as most humans would. CHESS
4.4'S tree size seems unrelated to the depth of the combination. CHESS 4.4 is of
course the best chess player of these three programs.
Table 3 shows where PARADISE invests its resources. The statistics are
compiled over the 89 problems which PARADISE-2solved. They give some idea
of the size of tree PARADISEgrows, the amount of time it spends, and where this
time is spent. (CPU time is in seconds on a KL-10 processor.)
Table 3 shows that calculating primitives is PARADISE'Smost computationally
significant activity. The fact that less than 9% of the nodes generated had static
analyses done on them shows that the plans do a good job of guiding the
search. Because of this, static analyses are not a major overall expense even
though an average one takes more than twelve seconds of cpu time. The
different cpu time limit given to PARADISEin Table 1 is due to the availability of
statistics, but is not as unfair as it seems. As Table 3 shows, PARADISE-2USeS an
average of only 5.5 minutes of cpu time on the 89 problems it solves. Also,
PARADISE could probably be speeded up by a factor of 2 or more with more
efficient production matching. As Table 3 shows, the program spends more
than 91% of its time in the inefficient production interpreter.
----" .
1 . . . .
involved pawn ending which goes well beyond the depth to which any current
program can reasonably search.) PARADISE-2could easily solve this problem by
including a production which tries to block a checking move by a piece
blocking a support of an en prise piece. Such a production could be expressed
in only a few lines in the production-language. However, this is unacceptable
because it is an ad hoe solution. The 'correct' way to find P--Q6 is by analyzing
the refutation of Q x R. This move is suggested by PARADISE'Scounter-causal
analysis but is not searched became offensive counter-causal moves are tried
only if they are caputures (see [13]). Changing this restriction would involve a
program change, so PARADISE-2cannot solve this problem. This problem would
be classified as a category 3 failure.
Problem 71 is a category 1 failure. The initial static analysis does not suggest
N × RPch which wins for white by enabling the white queen to move to OR3
and then up the queen rook file. The static analysis has the goal of moving the
white queen to OR3 and then up the queen rook file, so a fairly simple
production in the MOVE KS suggests N × RP at the top level. With this new
production PARADISE-2at first got the correct answer, but a bug in one of the
productions in the D E F E N D M O V E KS prevents some good defensive moves
from being tried at ply 4. When this defensive production is fixed, the search
becomes unbounded (i.e., uses more than 45 minutes of cpu time) because of
the many defensive and offensive possibilities. This is the only example of a
category 2 failure during testing of the program.
Position 91 is also a category 1 failure. Black can win a pawn and a much
superior position by playing B-K3. Black threatens mate with his queen and
knight and white must play B x N to avoid it, allowing P x B, 2. O--any P x Pch
winning a pawn. Whenever PARADISEsuggests mating sequences, it first expends
a large amount of effort doing a sensitive analysis of the upcoming possibilities.
Problem 91 must be understood on a similar level of specificity, since PARADISE
USING PATTERNS AND PLANS IN CHESS 197
uses this specific analysis to control the search. However, such a specific
production would require more than thirty minutes of human effort to design
and implement so PARADISE-2was not given credit for this problem.
designed to make it easy to produce new concepts (by writing productions and
forming KSs) for expressing plans whenever they are needed to handle new
'crazy side effects.'
In most robot planning systems, tests for having achieved the goal or the
preconditions of an action are trivial and give well defined answers. In chess,
there may be only very subtle differences between a position where a particular
action is good and positions where the same action is wrong. It is also hard to
know when a goal has been achieved, since there is always a chance of
obtaining a larger advantage (except when the opponent has been check-
mated). Thus in chess it is necessary for the plan to provide a considerable
amount of information to help in the making of these decisions. This is done in
PARADISEthrough the attribute lists in plans.
The number of things PARADISEcan consider doing at any point in a plan is
about an order of magnitude larger than the number of things most robot
problem solvers usually contend with. There are an average of about 38 legal
moves in a chess position (see [3]). A robot usually has a much smaller number
of possible actions which cannot be easily eliminated (for example, going to
one of a few rooms or picking up one of a few objects). When planning farther
in the future than just the first action, the chess planner has many more choices
than the 38 legal moves. The inability to make assumptions about future states
often prevents mentioning actual moves in a plan. Instead a description of the
intent is needed, and the number of such descriptions is much larger than the
number of legal moves that might be made. A robot usually has a much smaller
number of possible actions, so the two types of plans explode at very different
rates.
To summarize, the robot planners have the flavor of establishing a sequence
from a small number of well-understood operations until the correct order is
found, while chess planners have more a flavor of 'creating' the correct plan
from the many possibilities. For this reason, a system which produces good
chess plans needs a large amount of knowledge and non-trivial reasoning
processes to produce plans.
Probably the most important idea PARADISEhas for the robot problem solvers
is that a plan may be viewed as a way to control what parts of a large
knowledge base will be used to analyze each situation during plan execution.
Plans in PARADISEcan be viewed as telling the system what knowledge to use in
analysis, thus defining a perspective for the system to use in new situations.
Some amount of analysis from this new perspective is almost always done
before the plan can continue executing. In most robot planning systems plans
are more accurately viewed as telling the system what action to take. PARADISE
tries tO delay execution in order to bring more knowledge to bear.
13. Comparison to Plans in Chess
Pitrat's program [8], which solves chess combinations, is the most important
USING PATI'ERNS AND PLANS IN CHESS 199
example of the use of plans in chess. The language Pitrat uses for expressing
plans has four statements with the move statement and modification statement
being the most important. The move statement specifies that the piece on one
particular square should move to another particular square. It may also be
specified that the move must be a capture. The modification" statement des-
cribes a modification to be made to a particular square. This can be one of four
things: removal of a friend, removal of an enemy, moving a friend to the
square, or getting an enemy to move to the square.
Plans in PARADISE provide much more flexibility in expression that Pitrat's
move statement. In PARADISE, types of moves other than captures can be
specified (e.g., safe moves and safe capture moves). Also, particular squares do
not need to be named in PARADISEsince it can use a variety of goals to express
the plan. The important square to move to may change depending on the
opponent's move so it is not always possible to specify such a square in
advance. For example, if white makes a move which traps and attacks black's
queen then (after some desperado move by black) white would like to capture
black's queen wherever it may be. PARADISEcan express the planof capturing
the queen anywhere, while Pitrat's move statement cannot since the planner
does not know which particular square the queen will be on.
Pitrat's modification statement is a goal which the system tries to accomplish.
These modifications are too simple to express the purposes behind their
suggestion. For example, the system may want to decoy the black queen to
make a square that it protects safe for white. Pitrat would express this goal as
removing an enemy from the black queen's location which does not express the
purpose of the plan. It will work well for the winning combination but will also
allow many wrong moves since the queen may be decoyed to a square from
which she can still protect the square in question. PARADISEcan avoid this since
it has the ability to express its purposes. It can specify that the black queen
must be decoyed to make the particular square safe, and only decoys which
remove the black queen's protection will be considered. PARADISEwould also
specify that the move after the decoy should be safe so it will not be tried
unless the preparations have accomplished their purpose. PARADISEattempts to
express the purpose of each plan while Pitrat's plans express side effects that
will happen if the purpose is accomplished (e.g., a square becoming vacant).
Unfortunately, the same side effects may also happen when the purpose is not
accomplished, causing the system to waste effort searching poor lines.
Plans in PARADISEhave two more major advantages over the plans in Pitrat's
system. First, PARADISEhas conditionals which allow specification of different
plans for different replies by the opponent. The advantages of this are obvious:
the system can immediately try the correct plan instead of searching an
inappropriate plan and backtracking to correct itself. Second, PARADISE'Splan
language is modifiable. Simply by writing new productions, new goals and
concepts can be created for expressing plans and the system will automatically
200 D. WILKINS
understand these new plans. This property is necessary for any system that
wishes to extend its domain or incrementally increase its expertise. Significant
additions to Pitrat's plan language would seem to require a major programming
effort.
Despite the shortcomings of the plans in Pitrat's program, they are much
more sophisticated than any plans previously used in computer chess programs.
Pitrat's program performs well in its domain. It processes nodes much faster
than PARADISEand therefore can handle larger trees. The plans do an adequate
job given these constraints. It may be the case that programs will obtain better
performance by using Pitrat's approach of larger trees and less sophisticated
plans, but the use of knowledge is only starting to be investigated by programs
such as V^RAD~SEand it is too early to draw conclusions.
14. Summary
PARADISE exhibits expert performance on positions it has the knowledge to
understand, showing that a knowledge-based approach can solve some prob-
lems that the best search based programs cannot solve because the solutions
are too deep. The knowledge base is organized into KSs which provide
concepts for rARADXSEto use in its reasoning processes. These concepts are
higher level than the ideas produced by simply matching patterns. A single
pattern cannot recognize a whole plan of action in a complex chess position,
both pattern-level ideas and these higher level concepts are necessary in the
reasoning process.
The concepts provided by the KSs are used to create plans during static
analysis. The concepts communicate enough information that they can be
rejected after being posted. This keeps antithetical ideas from being combined
to produce ridiculous plans. The same concepts are used to express plans for
guiding the search, and the KSs execute the plans during the search. By
communicating plans down the tree, PARADISEcan understand new positions on
the basis of its analysis of previous positions. By having particular goals in mind
when looking at a new position, the system quickly focuses on the relevant part
of the knowledge base. Plans in PARADIS~ express their purpose fairly well,
without being too general or too specific. They contain enough additional
information to enable the system to decide when a line has succeeded or failed.
Because of the successful communication of knowledge through plans,
PARADISEis able to solve a number of chess combinations with small trees and
without a depth limit on its search.
P^RAms~'s knowledge base is amenable to modification. Production rules
(and therefore KSs) can be quickly written and inserted in the knowledge base
to improve system performance without adverse affects. Since KSs are used in
both planning and static analysis, modifications can improve both without
program changes. The range of expressible plans can easily be increased.
USING PATTERNS AND PLANS IN CHESS 201
15. Issues
One of the major issues in creating concepts is their generality. How 'high-lever
should a concept be? If the concepts are too general then too many details are lost,
and the system does not have the necessary facts to do certain reasoning. If not
general enough, the system leans toward the extreme of needing a production for
every possible chess position. The concepts in PARADISEhave been constructed to
be as general as possible without sacrificing expert-level performance to the loss of
detail. The factor limiting generality is the ability to communicate details in the
attribute lists of concepts. The generality in PARADISEhas made concepts in the
data base so complex that productions must essentially match patterns in these
concepts.
The tradeoff of generality and specificity in concepts is closely related to the
tradeoff of search and knowledge. With much specific knowledge the use of
knowledge becomes expensive, but fewer mistakes need to be corrected in the
search. Such a knowledge-based approach can solve deep problems (e.g.,
PARADISE has no depth limit), but may not be able to solve many problems,
even easy ones, because of holes in its knowledge. With more general know-
ledge, analysis is cheaper but more time must be spent correcting mistakes in
the search. Such a search-based approach often leads to a program which does
a full width search. Such programs almost always solve problems within their
depth limit, but cannot solve deep problems and suffer from problems like the
horizon effect (see Berliner [1]).
PARADISE USeS a mix of search and knowledge which involves more know-
ledge and less search than previous programs which include chess middle
games in their domain. The strength of the program depends on the complete-
ness of the knowledge base. Programs like CAPS and Pitrat's do not search all
legal moves and may also have holes in their knowledge. One might expect
PARADISE to miss combinations more often than these two programs since its
more specific knowledge suggests fewer moves, but this has not been the case
in the comparison of CAPS and PARADISE on the test portions. PARADISE
recognizes mating attacks that both CAPSand Pitrat's program miss. PARADISE'S
knowledge base appears complete enough to outperform CAPSon the first 100
positions in Reinfeld [9], even on positions within CAPS' depth limit. PARADISE-
2'S knowledge base is complete enough to outperform CHESS 4.4 on these
problems.
The primary justification for the cpu time used by PARADISEand the biggest
advantage of the approach used in PARADISE is the extendability of the
knowledge base. This means the effect of holes in the knowledge can easily be
reduced in PARADISE. The play of most programs cannot be noticeably im-
proved with easily made program or knowledge modifications. Improved play
would involve programming a more sophisticated analysis, or controlling the
search better so that it could search deeper. (Play can, of course, be improved by
202 D. WILKINS
ACKNOWLEDGEMENTS
The author is indebted to Hans Berliner for his continuing assistance and counsel during this research,
and to the Stanford Artificial Intelligence Laboratory which provided the necessary environment and
tools for doing this research.
REFERENCES
1. Berliner, H., Chess as problem solving: The development of a tactics analyzer, Unpublished
doctoral thesis, Carnegie-Mellon University (1974).
2. Charness, H., Human chess skill, in: P. Frey tEd.), Chess Skill in Man and Machine (Springer,
Berlin, 1977), Chapter 2.
3. De Groat, A. D., Thought and Choice in Chess (The Hague: Mouton, 1965).
4. Davis, R., Applications of meta level knowledge to the construction, maintenance and use of
large knowledge bases, AIM-283, Computer Science Department, Stanford University, 1976.
5. Fahlman, S. E., A planning system for robot construction tasks, Artificial Intelligence 5 (1974).
1-49.
6. Giilogly, J., The technology chess program, Arti~cial Intelligence 3 (1972) 145-163.
7. Kotov, A., Think Like a Grandmaster (Chess Digest, Dallas, 1971).
8. Pitrat, J., A chess combination program which uses plans, Arti)fcial Intelligence 8 (1977)
275-321.
9. Reinfeld, F., Win At Chess (Dover Books, 1958).
10. Sacerdoti, E. D., Planning in a hierarchy of abstraction spaces, Arti~cial Intelligence 5 (1974)
115-135.
11. Sacerdoti, E. D., The nonlinear nature of plans, Stanford Research Institute Technical Note
101 (January 1975).
12. Slate, D. and Atkin, L., CHESS4.5----The Northwestern University chess program, in: P. Frey
(Ed.), Chess Skill in Man and Machine (Springer, Berlin, 1977).
13. Wilkins, D. E., Using patterns and plans to solve problems and control search, AIM-329,
Computer Science Department, Stanford University (1979).
14. Wilkins, D. E., Causality analysis in chess, Proceedings of Third Conference Canadian Society
for Computational Study of Intelligence, Victoria, May 1980.
R e c e i v e d 16 A u g u s t 1979