You are on page 1of 10

L O N G - R A N G E P L A N N I N G IN

C O M P U T E R CHESS
Jonathan Schaeffer

University of Waterloo,
Waterloo, Ontario
Canada

ABSTRACT

A serious deficiency in game-playing, tree-searching programs is their short-


sightedness. Program strategy revolves around the maximization/minimization of
what is attainable within the scope of the search tree with little consideration of
what lies beyond. This paper describes Planner, a long-range chess strategist t h a t
assesses positions, determines a long-range strategy, and makes moves in the short-
term (within the scope of the search tree) consistent with a long-term objective
(beyond the depth of the search tree). In effect then, Planner allows the program to
"see" beyond the limitations of the search tree.

Permission to copy without fee all or part of this material is granted


provided that the copies are not made or distributed for direct
commercial advantage, the ACM copyright notice and the title of the
publication and its date appear, and notice is given that copying is by
permission of the Association for Computing Machinery. To copy
otherwise, or to republish, requires a fee and/or specific permission.
© 1983 ACM0-89791-120-2/83/010/0170 $00.75

170
1. I n t r o d u c t i o n search tree. After deciding on a long-
G ame-playing, tree-searching range strategy, the program can make
programs, such as for chess, usually moves in the short term (i.e., within the
suffer from myopia. If one builds a tree scope of the tree) consistent with a
t h a t is n levels deep (n ply], one may be long-range objective whose attainability
missing something important t h a t can may be beyond the depth of the search
only be seen by looking n+ 1 levels tree. In a sense then, the program can
deep. The use of sophisticated tree- achieve greater foresight.
searching techniques (alpha-beta, This paper describes Planner, a
iterative deepening, transposition tables long-range chess middlegame strategist.
[1], etc.) can limit the size of the game Planner is concerned with strategic
trees built, but for a typical middlegame (positional) plans that extend beyond
chess position, 9 ply is the current limit the depth of the search tree (see also
t h a t one can realistically expect to [3,4]), unlike other types of chess
search. Current solutions to this strategists which limit themselves to
problem are largely hardware based: tactical plans within the scope of the
build faster machines t h a t can search search tree [5, O, 7].
larger trees, extending the "sight" of the Planner to a large extent acts as a
program [2]. Although this does not pre-processor for a chess program. Each
alleviate the problem, it does help time it is the program's turn to select a
minimize its effects. move, Planner is called to analyze the
C o m p u t e r chess programs have position at the root node of the search
often been criticized for their superficial tree about to be constructed. After an
play. The reasons for this are obvious. extensive analysis, Planner selects an
The program selects its best move based appropriate long-range strategy. The
on what can be seen within the search selected strategy is used to construct
tree. On a move-to-move basis, each move scoring tables t h a t are used to
search tree is different and the move rank moves at interior nodes, and to
selected is not necessarily consistent help evaluate terminal nodes. Planner
with the previous move. This lack of also determines the features of the
continuity results in move selections position that caused a particular plan to
t h a t are the best in the short term, but be selected. This status information is
not necessarily in the long term. used on a move-to-move basis to
Chess grandmasters analyze determine if the original plan is still
variations as the computer does, but valid. During the tree search, it
they does so with a long-range plan in determines if the position has changed
mind. These plans are arrived at by a to such an extent as to invalidate the
detailed examination of the potential Planner move scoring tables.
possibilities that the position has to Planner consists of three major
offer. A strategy is then devised for modules: Plan Selection, Strategy, and
achieving these plans. Only once this is Move Generation. The Plan Selection
done does the grandmaster start to do module assesses the current position and
concrete analysis, keeping in mind the selects one or more plans based on t h a t
objectives that he has set out to assessment. For the chosen plan(s), the
accomplish. Strategy modules decides what has to be
Using long-range planning in chess accomplished, and how, by deciding the
programs, we can help minimize some of piece positioning likely to accomplish
the effects of short-sightedness of the that strategy. It passes to the Move

171
Generation module a list of pieces, the It is not sufficient to do long-range
squares we want them on, and the value planning for only one of the players.
of getting them there. From this The opponent, too, has a plan. In chess
information, the move scoring tables are it is as important to anticipate and
created. These tables serve to disrupt the opponent's plan as it is to
encourage moves to square(s) that best execute your own. Thus we call
contribute to the plan. Planner for white and black and store
the results separately.
2. Plan S e l e c t i o n One plan for each side is usually
~%en a grandmaster examines a not sutIicient; it is not an uncommon
position, one of the first things he does occurrence to be attacking on one flank
is to assess its long-range prospects: and defending on the other. T h u s one
'W~ere do I want to attack? Do I have a must allow for multiple plans. In fact,
weakness that needs defending? What Planner allows each side to have one
are my prospects, good or bad, in this offensive strategy and if necessary one
position? The answers to these defensive plan.
questions guide his subsequent play. The Plan Selection module not
Plan selection is the most only ehoses a plan, but also records an
important and, naturally, the most approximation of the the conditions
complicated phase of Planner. This under which t h a t plan is valid. This
routine does a detailed examination of information is used to decide when to
the position identifying the important terminate a plan, on a move-to-move
strategic features, such as the pawn basis as well as in the search tree. The
formation (weaknesses, blocked pawns, important positional feature(s) t h a t
potential levers, passed pawns, open files resulted in the plan(s) being selected are
and half-open files, etc.), center recognized and saved in various status
formation, piece placement and words. If any of these features change
distribution, and king safety. The significantly, this is used as an
routine attempts to identify which of indication t h a t the position has changed
these features are the most relevant to to the extent that the current plan(s)
the selection of a plan. This analysis are possibly invalid. More details are
may result in one of 13 plans being presented in Section 5.
chosen. Figure 1 lists the major plan
classifications. For each plan type, 3. Strategy
there is a template defining various Having decided on his long-range
board features that, if present, would be plans, the grandmaster now sets about
conducive to the selection of this plan. formulating how to implement these
Each plan type is examined in turn and chosen objectives. He will visualize
scored on its feasibility, practicality, and where on the board he wants each piece
likelihood of success. The plans with so t h a t it can contribute maximally
the highest scores, relative to a towards his goals. Then he goes about
dynamically determined threshold for deciding how (if at all) the pieces can be
each plan type, are chosen for manoeuvered to these optimal squares.
implementation. In the event that no The result is that for each piece, the
plan is found, a default "Wait" plan is grandmaster knows where he wants it to
invoked until such time as the program go and how to get it there. This
can come up with a suitable plan. information is used to guide his play for
subsequent moves.

172
Type Offence Defence
General Attack king-side Defend king-side
Attack queen-side Defend queen-side
Attack center Defend center
Specific Attack pawn weakness Defend pawn weakness
Occupy open file
Pawn break
Advance passed pawn Block passed pawn
Other Wait

Figure 1

Having decided on a course of queens, it is usually much more difficult


action, Planner must now generate a to assign it a "best square" because of
strategy for achieving these goals. Like its tremendous versatility. Instead, the
the grandmaster, Planner decides where queen is assigned a region of the board:
it wants its pieces located and devises a the closer to the region, the greater the
means for achieving these locations. contribution of the queen to the plan.
For each plan type, there is a strategy A simple example of a plan from
routine that uses the position features Planner'8 repertoire is attacking an
found by the Plan Selection modules as opponent's pawn weakness. For this
clues for deciding where the pieces plan, depending on the actual position,
should be located. This routine decides there may be three sub-plans. The first
where it wants its pieces (and where it one is to prevent the opponent from
does not) and calls the Move Generator liquidating the weakness. This may
to lay out a method for manoeuvering involve manoeuvering pieces/pawns to
the pieces from their present to their squares to restrain the weak pawn.
desired squares. After the weakness is fixed, the second
Each strategy routine uses the strategy is to attack the weakness as
information uncovered by the Plan many times as possible. Typically, the
Selection module to break the selected square in front of the weak pawn
plan(s) into one or more sub-plans; each (restraint) and the square of the pawn
directed at a different part of the itself (attack) are the ones that the
problem. The sub-plans may be very Strategist keys on. The third sub-plan
simple, such as to move a piece to a involves preventing the opponent from
specific square, or more difficult, such as defending the weakness. With this
prying open a file. The former involves strategy, Planner determines the most
only one piece and one square; the likely squares the opponent will use for
latter, several pieces and several squares. defence of the weakness and attempts to
The idea is to find the best square(s) for attack those squares. How successful
each piece (queen excepted) and for each this strategy will be depends on the ease
square, assign a value (priority) with which the sub-plans can be
indicating the relative worth of accomplished and the events happening
successfully attaining that square. For elsewhere on the board.

173
In addition, Planner recognizes its trail in order to maximize its score.
outposts (weak squares in the enemy's In assigning scores to squares in
camp) which it treats as sub-plans. the board image, it is necessary to
Occupation of these squares is usually of consider how likely the piece is to use
considerable value, even if the that square along the path in the near
occupation does not directly contribute future. If it is very unlikely, then the
to any of the plans chosen. Improving path in t h a t direction is discontinued.
the position of any piece is always If the path is blocked by a friendly
worth-while. There is no strategy piece, an examination is made to see if
required to occupy an outpost, so the it is feasible to move t h a t piece out of
list of outposts is passed directly to the the way. If not, the assignment of path
Move Generator. scores in t h a t direction is halted.
Otherwise, the scores along the path are
4. M o v e G e n e r a t i o n assigned to the appropriate squares.
Having decided where it wants its Just as certain squares are
pieces located, Planner then determines desirable, so are some undesirable. The
how to get them there from their board images can have negative scores
current position. This may be a trivial placed on squares deemed poor, thereby
task in the case where a piece is already making it very unattractive for a piece
on its best square, or can move there to move there.
directly. But usually it is not so
Figure 2 illustrates the concept of
obvious; a square in the way may be
the board image. Here we want to
attacked or occupied so that several
manoeuver a knight from C1 to FS. If
moves are required to successfully
F5 is to be occupied, we give t h a t
deploy the piece.
square in our board image full value of
The information on where and how the score given by the Strategy module.
to move the pieces is used in position If the square is only to be attacked, we
and move evaluation by the host chess give t h a t square a value of zero to
program. As these evaluations comprise discourage pieces from actually moving
a high percentage of a chess program's to it.
total execution time, it is essential to
All squares that can be safely
store the Move Generator information in occupied by the piece and are one move
a data structure t h a t allows very fast
away from the desired square receive
retrieval. The structure used is called a part of the total score. Similarly, all
board image - an array of 04 elements
safe squares t h a t lead to squares t h a t
with a score for each square on the
can reach the desired square in one
board (along the lines of Botvinnik's move receive a smaller percentage of the
maps/3D. There is one image for each total score. In Figure 2, the F5 square
piece type and colour. The value for a receives a score of 10 as determined by
given move is then the value of the the Strategy routine. All squares t h a t a
square moved to less the value of the knight could safely occupy and be
square moved from. within one of F5 (such as H4, G3, E3,
To entice a piece to move from its and D4) receive 8 points; half the total
current square to a square consistent score. Squares within two moves of F5
with the selected plans, we use the (e.g., B3 and E2) receive half of the
board images to contain a "trail" of value of squares t h a t are within one
successively increasing scores t h a t lead move. Note t h a t Figure 2 shows scores
to the desired square. A piece follows assuming an e m p t y board. In practise,

174
8
0 0 4 0 4 0 4 0
7
0 4 0 0 8 4 8 0

6
0 0 4 8 4 0 4 8

5
0 4 0 4 0 16 0 4
4
0 0 4 8 4 0 4 8

3
0 4 0 0 8 4 8 0
2
0 0 4 0 4 0 4 0
i
1
!0 0 N 4 0 I 4 0 4

A B C D E F G H

Figure 2

the board image is sparser because most journeys from C1 to F5. The Planner
paths are found to be impractical. scores attempt to bias chess program
Now examining the knight on C1, scoring mechanisms towards moves that
we can easily see how it can be are consistent with a plan.
manoeuvered to F5 if we know that The grandmaster will look at a
chess programs try to maximize scores. piece's position and determine a method
The knight on C1 would prefer to move of moving the piece from its current
to E2 or B3 (score 4) than to any other location to its desired location. The
square (score 0). Once on B3, the Move Generator, in a sense then, works
knight's best move is to D4 (score 4). backwards. We start with the desired
Finally, once on D4, the knight can position and move backwards towards
achieve its goal and move to F5 for an the current position. Programming
additional 8 points. Thus the knight techniques that emulate the human
follows a trail to maximize its point approach have had limited success
gains; deviating from this path earns because it is ditficult to find a correct
negative or zero scores, much to the path given that squares along it may be
chess program's distaste. unsafe or occupied. Working backwards
Note t h a t the board images merely has the advantage of leaving a trail
provide scores to be used in evaluating behind for every feasible path that can
moves. The chess program must also safely lead to the destination. Move
evaluate the move and score it on other scoring mechanisms easily force pieces
factors (material, king safety, pawn onto such paths if they are not already
structure, for example) as well. It is the on them.
combination of these scores that will Figure 3 shows the situation where
determine if and when the the knight H5 (value of 20) and F5 (value of 16)

175
are both set as desirable. Under these strategy) score more favourably. This
circumstances, the optimal path for the factor is particularly noticeable in
knight on C1 is unambiguous: from C1 positional chess games. The scorcs
to E2 to G3. This move sequence leaves associated with each individual move
both options, F5 and H5, open. Note can also be used at the interior node to
t h a t moving the knight from C1 to B3 help determine the order in which the
to D4, as in the previous example, is moves should be examined. Tree
now less flexible - an important chess searching is much more efficient if you
consideration. search the best move at the interior
node first [1]. If you are using an
5. T r e e S e a r c h i n g alpha-beta tree pruning mechanism, this
can result in more cut-offs. The interior
The Planner score for each move
node ranking mechanisms can use the
considered at an interior node of a
Planner scores as additional information
search tree, can be computed by looking
which does result in a better ordering of
in the table for that piece. As one
moves and hence (minimally) smaller
descends the search tree, the scores
search trees.
associated with each move in the
sequence are summed to give a net score During a tree search, positions will
(white scores - black scores) that can be often arise that do not agree with
used to help score terminal nodes. In assessments made by Planner at the
this manner, positions that were root node. Events on the board can
achieved through play consistent with change very rapidly, depending on the
long-range strategy (or alternatively, moves made. The chess program must
with prevention of the opponent's be able to recognize when conditions
have changed enough to invalidate the

8 0 [0 4 0 9 0 9 0

7 0 4 0 5 8 4 18 5

6 0 0 4 8 9 10 9 8

5 0 4 0 9 0 21 0 24

4 0 0 4 8 9 10 9 8

3 0 4 0 5 8 4 18 5

2 0 0 4 0 9 0 9 0

I 0 0 N 4 0 9 0 9

A B C D E F G H

Figure 3

176
Planner tables. T h e Plan Selection More recently, Planner has been
module computes a variety of status used in the University of Waterloo chess
information t h a t defines the position programs Prodigy (1981 North American
conditions necessary for the plan. If Championships participant) and
these conditions change significantly, it Phoeniz. Both these programs play
is doubtful t h a t the plan is still reliable. consistently better chess with Planner
Therefore one has a standard against than without as numerous training
which to measure the current position, games have shown.
and to determir~e the validity of Planner Analysis of games played by
scores. If the two agree within certain programs using Planner have pointed
limits, the plan endures. Once the out some important problems
current position's value disagrees with introduced by long-range planning.
the root position to a significant degree,
the Planner scores are ignored and play The selection of plans by Planner
no role in subsequent analysis for that is acceptable, though far from perfect.
particular sub-tree. For example, if the In most positions, a reasonable plan is
current plan is to block a passed pawn, chosen and carried out reasonably
during the tree search in lines where the consistently. However, Planner can bc
passed pawn is captured, Planner's fooled into poor plan selections resulting
scoring tables are turned off. in some pretty bad (but consistent!)
chess. One can make the excuse t h a t
The status information is also used these errors are a result of insufficient
on a move-to-move basis. At the root chess knowledge, but the problem is
node of each search tree, a comparison really more of inflexible knowledge.
is done between the features of the Patterns for plans can come in various
position and the status information. If guises under varying circumstances.
they agree within a limit, the current Any sort of non-generalizing knowledge
plan is continued and only the move cannot hope to cope with all possible
scoring tables are updated. If they scenarios properly.
disagree, then the Plan Selection module
is called in to choose a possibly new Another problem is timing. The
plan. This feature allows the program program tries to maximize the score for
to have a measure of consistency over a a position and thus likes the moves t h a t
series of moves. give the highest scores from the move
scoring tables. But there are many
types of positions where the moves t h a t
6. R e s u l t s
are scored highly by Planner are better
Planner was originally interfaced delayed so as to achieve an even greater
with the chess program Tree.frog (1974 effect on the position. A good example
North American Champion, 2nd place is the pawn break. The program will
tie in 1st World Championships). In push the pawn forward at the first
1980, a match was carried out between possible opportunity because there is a
Treefrog and Treefrog supplemented by high score associated with doing this,
Planner. A set of 5 standard opening However, delay of the break until all
positions was selected for the match, your pieces are in their proper position
with the programs playing each position may make the actual pawn break even
from both the white and black side. stronger.
The result was 8 wins and 2 draws for Another problem is a version of the
the Planner version of Tree frog.
horizon effect[8]. During a tree search,
when the program detects t h a t a plan is

177
no longer valid, it turns off the Planner 8. A c k n o w l e d g m e n t s
move scoring tables. The program then Randy Goebel and Amy Goldwater
tends to select lines of play which push greatly enhanced the readability of this
the plan termination condition to the manuscript,
last ply of search (so as to maximize the
amount of Planner score it receives). In
9. References
a sense this problem is the opposite of
the first one mentioned - procrastination
vs haste. This problem was not evident [11 T.A. Marsland and M. Campbell,
in programs that searched shallow trees, Parallel Search of Strongly
but as the level of ability of programs Ordered Game Trees, Computing
that have used Planner has increased, it Surveys 14(4), Dec, 1982.
became a serious problem (directly
resulting in the loss of 1 tournament [21 Joe Condon and Ken Thompson,
game). As a result, in the chess Belle Chess Hardware, Advances in
program Phoeniz the move scoring Computer Chess, vol. 3, Pergamon
tables are not turned off during tree Press, 1982.
searching.
[3] Mikhail M. Botvinnik, Computers,
7. C o n c l u s i o n s Chess and Long-range Planning,
Planner has proved to be an The English Universities Press
invaluable aid for increasing the playing Ltd., London, England, 1970.
abilities of chess programs. At the
University of Waterloo, the succession of [41 H. Kaindl, Positional Long-Range
chess programs Treefrog, Prodigy, and Planning in Computer Chess,
Phoeniz have all used Planner to Advances in Computer Chess,
advantage. vol. 3, Pergamon Press, 1982.
For Prodigy, a version of Planner
was implemented for endgame positions. [5] Jacques Pitrat, Using Plans in a
The program's structure is basically the Chess Playing Program, 5th
same as the one described in this paper. International Joint Conference on
However, endgame play requires Artificial Intelligence vol. 2, 1977,
different types of plans and strategies Cambridge, Massachusetts.
than does middlegame play. It is
interesting to note that for some
simplified endgame positions (king and
[0] Jacques Pitrat, The Behaviour of a
Chess Combination Program using
pawn endgames), Planner can actually
Plans, A dt,anees in Computer
play winning move sequences with as
Chess, vol. 2, Edinburgh
little as a one ply search, even though
University Press, 1980.
the solution requires 25 ply. In these
positions, conventional programs fail to
find the solution because of the need to [7] David Wilkins, Using Patterns and
look very deep. These shallow tree Plans to Solve Problems and
searches are possible only because the Control Search, STAN-CS-79-747,
program has a plan that it executes by Computer Science Department,
making moves in the short-run (1 ply) Stanford, 1979.
consistent with its long term objective
(25 ply).

178
[8] Hans Berliner, Chess as Problem
Solving: The Development of a
Tactics Analyzer, Department of
Computer Science, Carneige-Mellon
University, 1974.

[9] Jonathan Schaeffer, Long-Range


Planning in C3mputer Chess,
M.Math dissertation, Computer
Science Department, University of
Waterloo, 1980.

[10] Peter Frey, Che88 Skill in Man and


Machine, Springer-Verlag New
York Inc., New York, 1977.

179

You might also like