Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Algorithms For A Minimal Chess Player

Download as pdf or txt
Download as pdf or txt
You are on page 1of 25
At a glance
Powered by AI
The paper describes algorithms for developing a basic chess player that can play quickly (under 1 second per move) by using specialized searches and representations rather than standard lookahead. Tactical searches are used to discover specific features like mates.

The goal was to develop a chess player that could utilize its full allotted time per move (normally 1 minute) while consistently using around 1 second per move to achieve maximum quality without requiring exponential time with increased play strength.

The paper describes a basic chess environment representation, Lasker regions, and over 14 algorithms or chess predicates and functions that are used as a 'chess language' to create the blitz player, including specialized tree searches and the alpha-beta algorithm.

Int. J.

Man-Machine Studies (1971) 3, 141-165

Algorithms for a Minimal Chess Player: A Blitz Player

EDWARD W . KOZDROWICKI, JOHN S. LiCWINKO

Department of Electrical Engineering,


University of California, Davis, Calif. U.S.A.

AND DENNIS W . COOPER

Bell Telephone Laboratories,


Whippany, N.J., U.S.A.

(Received 18 December 1970)


The blitz player plays at a rate of under 1 see/move on most machines. This paper
describes a basic chess environment representation along with corresponding Lasker
regions and over 14 algorithms or chess predicates and functions. Those predicates
and functions are used as a "chess language" to create the blitz player. Standard
look-ahead procedure is not used in the bRtzmode although specialized tree searches
are used to look for specific features. The well-known alpha beta algorithm is used for
one specific search and in this mode alpha-beta procedure precisely simulates
human thought processes. In addition a tree searching language (TSL) is used to
construct a MATERtree to attempt to discover mating combinations by a series of
cheeks and mate threats.

Introduction
The p u r p o s e o f this p a p e r is to isolate a n d describe some f u n d a m e n t a l chess
algorithms. I t is clear f r o m the l i t e r a t u r e t h a t m a n y g r o u p s f r o m all p a r t s o f
the w o r l d are w o r k i n g o n chess p r o g r a m s . Thus it is i m p o r t a n t to r e p o r t al-
g o r i t h m s in o r d e r to p r e v e n t their r e p e a t e d rediscovery. A m i n i m a l chess
p l a y e r is defined here as one t h a t d o e s n o t o p e r a t e in the region where the
execution time p e r move is clearly a n exponentially increasing function o f the
quality o f play.
I n 1968 chess p r o g r a m d e v e l o p m e n t b e g a n at University o f California,
Davis ( U C D ) with :
(1) a tree searching l a n g u a g e (TSL) which e n a b l e d a n easy a n d effective
i m p l e m e n t a t i o n o f a search p r o g r a m (Kozckowicki, 1968a, b);
(2) a legal move g e n e r a t o r a n d ;
(3) a MATER I p r o g r a m ( B a y l o r & Simon, 1966) i m p l e m e n t e d in TSL.
142 E . W . KOZDROWICKI, J. S. LICWlNKO AND D. W. COOPER

The goal from the offset was to develop a minimal player. TSL would then
be used to produce "well formed search trees" allowing the machine to
utilize its full allotted time per move to achieve maximum quality. The allotted
time per move was normally one minute while the minimal game player
consistently used in the neighborhood of one second. After one year the
program could compete with most non-club players. In the following year,
while at Stanford, Cooper (1969) continued development which incorporated
chess logistics into tree searching and produced an improved TSL. That
program--COKO III (the Cooper-Koz chess program)--was a strong
contender (lower B class) in the first ACM computer chess championship in
New York (29 August 1970). At UCD work continued on the blitz player or
minimal chess player. The blitz player currently competes at lower chess club
level and has worked 27 of the 40 puzzles in the section on "Brilliant Chess
Combinations and Sacrifices" of Reinfeld's book (1955). This was at a blitz
rate of under 2 seconds per move on the IBM 7044.'~ Like most tournament
players the blitz player also has a good opening (on the basis of principle), a
shaky middle game and a weak end game. It can easily win against players
who leave an occasional pawn en prise. Currently the blitz player is being
merged with coKo III which achieved 24 of Reinfeld's puzzles, before the
ACM championship, at a tournament rate of play.

Doe's Delight
Doc Ross,:~ whose chess ability grew along with the machine, has been the
computer's most ardent competitor. Occasionally playing throughout the
night, when the machine was otherwise idle, he would emerge in the morning
elated, having repeatedly trounced the machine. Figure 1 illustrates his
unorthodox openings, used when he discovered the machine's weakness in
-R -N -B -K -B -N -R
-p -p -p -p ~ -p -p

* ,)( . -P -Q ,

~ B P P ~ * -p
}( }( ~ N ~

P P P ~( ~ P P P
R N B Q K )~ * R
FIG. 1. The opening strategy for Doc's delight. Doc plays black.
t The program is entirely in rORTPa~Nwithout a single assembler language instruction,
i.e. it is completely machine independent.
$ UCD ComputerCenterStaff.
A MINIMAL CHESSPLAYER 143

handling the pawn structure in front of the castling position. The machine's
pawn structure improvement later led to a frustrating evening of defeat
resulting from such unorthodox openings. Doc's second delight came when he
discovered that the machine would tend to castle immediately after but not
before all minor pieces were developed. His third delight is current with both
the minimal player and cor[o III. The strategy is to continually sacrifice
pieces to build up a powerful king offensive. Being greedy for material the
machine does not see what is coming before it is too late. Throughout the
program's development it has in effect been assumed that upon loss of material
or sufficient strategic position the opponent would stoutly resign, as masters
would. The cause and correction o f Doc's delights will be further discussed.

.& Minimal Chess Game


Figure 2 illustrates a minimal game for White's opening move. Each legal
-R -N -B -O -K -B -N -R
-p -p -p -p -p -p -p -p

"1( .)( -l( ~ '1~ -~

P P P P P P P P
R N B O K B N R

P-Q4 136
P-K4 136
P-Q3 108
P-K3 108
N-QB3 105
N-KB3 105
N-QR3 85
N-KR3 85
P-QN3 20
P-KN3 20
P-QN4 14
P-KN4 14
P-QI34 5
P-KB4 5
P-QR4 2
P-KR'4 2
P-QB3 -4
P-KB3 -4
P-QR3 -9
P-KR5 -9

FI6. 2. A minimal chess game for White's opening move.


144 E . W . KOZDROWICKI, I. S. LICWINKO AND D. W. COOPER

move is listed and given a number representing the relative quality of the
transformation. Each legal move must be included in the set of scored moves
otherwise an element of randomness would be introduced. The creation of
scores for the moves of such a minimal game is the main subject of this
paper and will be discussed along with the treatment of the Lasker regions,
chess predicates and functions, forks, and sacrificial combinations. Next the
concept of the Fisher set is introduced and look-ahead procedure, as per-
formed automatically by TSL, is described. Finally, a mating combinations
procedure is described which employs well documented chess predicates and
the tree searching language to produce a MATERtree.

Chess Environment Representation


An effective~ machine representation for the chessboard is illustrated in
Fig. 3. The numbers 1 through 6 represent the pieces; positive for the machine;
negative for the opponent with empty squares as zeros. Sevens are border
squares on the 12 x 12 board. A linear array of 144 consecutive memory
locations allows efficient movement of the pieces and border detection. The
use of 80 border squares actually results in both time and memory savings as a
single test (for 7) determines whether or not a piece is attempting to move off
the board. The legal move directions are represented by an array of 16 num-
bers; 8 of which are shown in Fig. 3(c). If the only piece on the board was a
bishop on square 27 (QR1)its 7 legal moves would be generated by succes-
sively adding 13 until a "7" was finally found on square 131 [see Fig. 3(a)].
Attempts to move in the other 3 bishop directions ( - 1 3 , -11, + 11) would
encounter immediate border squares. Castling and en passant moves must be
handled deliberately and takes up nearly 5 % of the total program.

Pre-analysis---Fixing the Lasker Regions~:


This program is designed to solve puzzles with a game being merely con-
sidered as a sequence of such puzzles. Upon presentation of a puzzle the
pre-analysis program takes stock of the situation just as a human player
would. It counts pieces, determines castling legality, examines the previous
t Through private communication and through publications it has been discovered that
this representation is not so obvious. Some of the best existing chess programs still use the
2-dimensional array with limit tests on b o t h indices as originally suggested by Shannon
in 1950.
Edward Lasker (Gardner, 1959), an American chess expert, once suggested that it is
nonsense to think a computer would ever play master chess. He felt the computer could
not have an intuitive feeling for unified regional mobilization of forces. Thus we have re-
ferred to such regionalmappingsas "Lasker Regions".
A MINIMAL CHESS PLAYER 145

13'3 134135 [56 137138 139 140141 142 143144


121 122123124125126127 I28129150131132
109 I10 III 112 113 114 115 116 117 118 119 120
97 9E 99 I00 I01
85
73
61 62 63
49 5C 51 52
37 38 39 40 41 42 43 44 45 46 47 49
25 2E 27 28 29 30 31 52 33 34 :35 36
13 14 15 16 17 18 19 20 21 22 23 24
I 2 3 4 5 6 7 8 9 I0 II 12
(a)

7 7 7 7 7 77 77 777
7 7 7 7 7 77 77 777
7 7 -4 -2 -3 -5 -6 -5 -2 ~3 7 7
7 7 -I -I -I -I -I -I -1 -1 7 7
: 7 7 77
'7 7 0 77
7 7 0 0 0 77
7 7 0 0 0 0 0 77
7 7i I I I I 1 1 1 1 77
7 7 4 2 3 5 6 3 2 477
7 7 7 7 7 7 7 7 7 777
7 7 7 7 7 7 7 7 7 777
(b)
7 7 0 0

-I3_ 1 ~ 2 _I I 77 77 0N 00 00
-I I
7 7 7 7 7
(e) (d)
FIG. 3. Chess environment representation: minimal game board. (a) The chessboard
represented by a linear array. (b) Representation of pieces, empty squares and border
squares. (c) Move directions for king and queen. (d) The knight dictates a 12 x 12 board.

move to determine the legality of an en passant, capture, establishe s all pins,


X-ray attacks, discovered attacks, squares with en prise pieces, exchange
squares, etc., and maps the Lasker regions. Although originally expected that
pre-analysis would be a large task the corresponding program is short and
efficient.t
Strategic areas of the board are mapped on a set of region boards (Lasker
maps) similar to the board of Fig. 3. Thus, regional information can be
t This also implies that, to a much larger extent than common belief, the human player
also solves a sequence of puzzles during the course of a game. In fact, Fine (1967) was
mystified by the fact that "When it is not his turn to move, the p l a y e r . . , daydreams, and
his d a y d r e a m s . . , have nothing to do with chess."
146 E . W . KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

obtained very easily and at high rate. Figure 4(b) shows the pin board map-
ping for the example position of Fig. 4(a). The simplest region is the center
defined as the 4 central squares and coded with a - 7 0 . While evaluating
moves the program can rapidly test the pinboard, for - 7 0 , to determine
if the moved piece would reside in the center or possibly attack the center.
For example, if all the squares to which the knight on KB3 of Fig. 4(a)

-R }( ~ }( * -R -K .
W }( ~ )~ w -P -P -P

P Q ~ ~ N ~
P B P w . P B P
R w w * K . * R

(a)

-I011~ )~ )~ * -60-60 -60


~ w ~ ~ -60 113 - 6 0
~ ~ ~ ~ 12021:3~ )~
~ ~ -70 -70 , ,
• , -70-70 . ~
• 13 * ~-20211 . .
- 5 0 - 5 0 -50-51 ' - 5 1 - 5 0 - I 11 - 5 0
-51 -51 ,'~ * - 5 1 -51 *

(b}
PiG. 4. The pinboard. (a) Sample board position. (b) Corresponding pinboard setting.

could legally move were generated, the pinboard would contain - 7 0 for 2
of them. Likewise, all the squares adjacent to the opponent's king are given
numbers ( - 6 0 ) marking the king sector. As illustrated in the example of
Fig. 4(b) more important information, such as the 113 on KN7, can overlay
the king sector code J" Thus "most" king sector attacks can be easily detected.
The pawn structure in front of the castled position or the potential castling
positions is coded with a - 5 0 . If the machine is considering a pawn move,
it can rapidly determine if it will harm the castled position by testing the
pinboard. Here is the cause of Doc's delight as illustrated in Fig. 1. The
pawns were given too large a penalty for moving thereby failing prey in a
near frozen position. After castling the pawns on the opposite side are
released by not setting the code.
? The pinboard is a well clustered Lasker map due to the core memory limitation of
the IBN 7044.
A MINIMAL CHESS PLAYER 147

On the condition that castling is still possible the castle structure region is
coded with a -51. For the calculation of Fig. 2 the top 8 moves received a
50-point bonus for clearing the castle region. Clearly the correct group of
moves are set aside in a class of their own. The source of Doc's second delight
occurred when the weight for castling was overpowered by the incentive to
clear the entire castle region. With such weighting, a bishop frozen on K2
could prevent castling. This feature alone is not sutficient for good openings
but the corresponding program is simple and makes a good group classifica-
tion. Openings could be varied by setting a random castle structure region,
e.g. a - 5 1 on KN2 could cause a king's Indian defense.
In Fig. 4, the white queen pins the knight against a pawn. The pin is found
by removing the knight and then determining if the pawn is left en prise. On
the pinboard the square with the pinning piece (QB3) is coded with the "pin
direction" (Shannon, 1950). Thus at some later time it can be easily deter-
mined if the moving of that piece will or will not relinquish a pin, e.g. moving
in other than the plus or minus pin direction breaks the pin. The square
corresponding to the "pinned against piece" is coded with pin direction plus
100 [113 in Fig. 4(b)]. In general, moving this piece in a direction other than
the pin direction will break the pin. The square corresponding to a pinned
piece is always greater than 1000. It contains the direction plus 1000 times the
en prise value of the piece pinned against. This yields immediate information
as to the strength of the pin (the 200 is needed so that a negative pin direction
doesn't modify the en prise strength).
If it were not for the mating threat the number on KN6 would be 1213
indicating that the pinned against piece had a potential en prise value of a
pawn, the classical piece value being 9,5,3,3,1 with 120 being arbitrarily used
for the king. Since moving the knight could lead to mate, the knight square is
coded as if it were pinned against the king itself. The mate threat pin itself is
easily discovered using the mate threat predicate (MT THRT) to form the
regional mapping. Complications such as the opponent knight itself protect-
ing the mating square must be accounted for by execution rather than flatly
relying on region information. As an example the move P-KN5 attacking the
pinned piece would trigger additional evaluation that would discover the
easy reprotection of the mating square.
The main value of the Lasker regions is that they allow an optimum use of
information discovered during pre-analysis to direct execution during move
evaluation.
In Fig. 4 the bishop on KN2 has an X-ray attack (through his own knight),
on the opponent's rook, in the + 11 direction. With the knight removed the
en prise value of the rook is 2 (rook minus bishop) indicated by the ten
148 E. W. KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

thousands digit of the number (-20211) on the knight's square. The notation
for X-rays is the same as for pins except the numbers are negative and in-
corporate an extra digit. The extra digit is necessary for distinction between
X-raying pieces and pinning pieces (negative directions exist). A precedence
order has been established for information overlapping identical squares.
Center, pawn structure and king sector regions are frequently overlapped
with X-ray and pin information in that respective order.
Figure 5 illustrates the exchange board. This region board contains useful
information for attempting combinations. Associated with each piece on the

-Q x ~ , -P -P

* ~ ~ * Q ~
w w ~ W ~ W W K

(a)

~ ~ ~ * I00300 *
I00 ~( ~ w 022022

~ ~ ~ ~ I00 ~

(b)
FIG. 5. The exchange board. (a) Sample board position. (b) Corresponding exchange board
setting.

game board is a positive 3-digit number stored on the exchange board. Each
digit gives information concerning the participation of a piece in an exchange.
The hundreds digit indicates the number of other pieces protected by that
piece, the tens digit indicates the number of attacks on that piece itself and the
ones digit indicates the number of pieces that protect it. Thus the opponent
queen location on the exchange board contains 100, meaning the queen is
protecting one piece, the queen is not attacked and is not protected. Likewise,
the king protects 3 pieces. The pawn on the exchange square (KB7) protects
no other pieces, is attacked twice and is protected twice.
All en prise pieces are indicated on the exchange board by a negative
A MINIMALCHESSPLAYER 149

number, its value being the expected loss of material. While the exchange
board is being set, a list is made of the en prise pieces and a separate list is
made of all the opponent pieces subject to exchange. An interesting statis-
tic is that the exchange list tends to be rather small, therefore, pieces subject
to exchange can be re-examined at high frequency, e.g. after minor perturba-
tions of the state (board position). An exchange list is a list of all opponent
pieces under direct attack by machine pieces.
Once the pre-analysis of the situation is complete and the Lasker regions
have been determined, evaluation for move selection may commence.

Fundamental Chess Predicates and Functions


Most important to constructing a chess program is the building of a funda-
mental set of predicates and functions that can be used as a command hier-
archy for program creation. They must operate on the above described chess
environment and Lasker regions. A predicate is a function that operates on a
group of input variables and produces a logical truth value. Such predicates
can then be tested to result in a decision making hierarchy.
The attack square predicate (sub program) is illustrated in equation (1).

IF (ATK SQ (SQ, A T K LST, NM A T K S ) ) ~ (1)


$
It is used to produce a list of pieces bearing on a particular square. The
first argument, SQ is assigned the numerical value of the target square on the
minimal game board. For the illustration of Fig. 6 the target square is Q4

W- -w -R
W W * w-

-N-P\ jB x

-~-N ~ ~ -w- N
W- ~ Q W
W W W R $$ R W 'I~

(o)

N -N N P
,I
B R -P
I
Q -B -R _
I
R
(b)

FIG. 6. The EN PRIS algorithms ordering problem. (a) Sample board position. (b) Linear
attack list for pawn on Q4. Actually square numbers are stored rather than pieces.
150 E . W . KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

(actually square number 66). All the squares containing pieces which bear on
the target square are loaded into the list indicated in equation (1) as ATK
LST. N M ATKS returns the number of pieces bearing directly on the target
square. The predicate, ATK SQ is FALSE only on the condition that no
pieces bear on the target square or NM ATKS is zero.
The example of Fig. 6 illustrates the scheme used for preservation of the
ordering of attacking pieces. If SQ is assigned the value of the Q4 square
for the position of Fig. 6(a) the ATK LST would appear as shown in Fig. 6(b).
All of the knights bearing on the target square are the first elements of the
list. Next all the pieces that bear directly on the target square are listed
with 8 as a maximum. Any piece behind a piece bearing directly is displaced 8
units along the list, e.g. - B is displaced 8 units from B. A sufficient list
size of 32 allows up to 4 pieces in line. NM ATKS would be returned with a
value of 8 for the position of Fig. 6(a). Unless specially requested, the ATK
LST does not contain strongly pinned pieces. ATK SQ is the most generally
used program or predicate.
A most useful subprogram which employs ATK SQ, determines whether
or not a piece is en prise as illustrated by equation (2).
IF (EN PRIS (SQ))-~ (2)

The input argument (SQ) is the square on which the piece resides and the func-
tion variable, EN PRIS is logical. This function returns 3 other variables
through COMMON (equivalent to GLOBAL),
(1) PER SAF is TRUE if the piece cannot be captured, even at a loss it
is perfectly safe. This information is particularly valuable for
mating threat evaluation.
(2) PSUD SF (pseudo safe) is TRUE if the piece is subject to an even
exchange.
(3) EP SCR (enprise score) is the exact amount of material to be lost in
the exchange, if any.
The EN PRIS algorithm must take pinned pieces into account. As defined
here the knight of Fig. 7 would be evaluated as follows. In Fig. 7(a), the
-p , -B , -e ~ -Q
-p ~ -p ~ -P ~
N ~ N ~ N N

Q ~ Q ~ Q -~ Q
(o) (b) (c) (d)

FIo. 7. EN PRIS algorithm. (a) EN PRIS; (b) PSUD SF; (c) not EN PRIS; (d) PER SAF.
A MINIMAL CHESS PLAYER 151

knight is EN PRIS with an EP SCR of 2 (knight minus pawn). It is possible


that contrived positions could produce errors. In Fig. 7(b), the knight is not
EN PRIS and is PSUD SF while in Fig. 7(c), it is not EN PRIS and is not
PSUD SF. In Fig. 7(d) it is PER SAF.
A most essential program is the legal move generator used as shown in the
form of equation (3).
IF (LGL MV G (SQ FM, SQ TO, M N M VS))~ (3)

L G L MV G is FALSE if there is no legal move generation or the piece in


question can make no moves. The first argument, SQ FM is a square number
on the chess board of Fig. 3. This routine produces all legal moves for what-
ever piece resides on that squarel All the squares to which that piece can move
are loaded into the list indicated in equation (3) as SQ TO. SQ TO must be of
size 27, the maximum possible number of queen moves. L G L MV G is
normally used to load several such lists simultaneously during play. NM
MVS is the corresponding number of moves. The legal moves for the minimal
game, as shown in Fig. 2, are simply obtained by varying SQ FM over the
entire board.
IF (PRT SQ (SQ, PRT LST, NM PRTS))-~ (4)

For the PRT SQ predicate, SQ is the square on which the piece of concern
resides, PRT LST is a list of squares containing pieces protected by the piece
on SQ, NM PRTS is the number of pieces protected and PRT SQ is FALSE
only if NM PRTS is zero.
The SAFE SQ program is the heart of the chess algorithms allowing risky
moves to be considered.
IF (SAFE SQ (SQ))~ (5)
$
In Fig. 8, the pawn moving forward would become EN PRIS. It is actually a
safe move, however, since its capture would leave a bigger (or equal) piece EN
PRIS. The pawn move could well be the best for the minimal game because

-N ~ -B
~ -N

l~. 8. A move to a SAFE SQ.


152 E . w . KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

the move is safe and attacks a pinned piece. Though extremely important,
SAFE SQ is a very simple program. It is made up of:
(1) A call to ATK SQ.
(2) Repetitive calls to PRT SQ.
(3) And numerous calls to EN PRIS.
The real power of SAFE SQ lies not so much with minimal chess but with the
use of look-ahead procedure. A safe move is frequently good but not neces-
sarily for obvious reasons. It is this algorithm, combined with look-ahead,
that produces moves that appear as if created through intuition.
For the SAFE SQ evaluation of the position of Fig. 8 the pawn is actually
moved, ATK SQ yields the square (SQ) of the attacking knight and PRT SQ
is evaluated for the knight. For this evaluation the exchange board allows
optimization. If the correspondence knight square on the exchange board was
to contain a number less than 100 then it could not be protecting another
piece and further evaluation would not be necessary. After discovering that
the knight bears upon a second knight the tens digits o f the corresponding
exchange board square of the second knight is examined. If the tens digit is not
zero, i.e. meaning the second knight is under attack, then the move, NxP must
actually be made followed by an EN PRIS test of the second knight.
The board position of Fig. 9(a) is used to illustrate the employment of the
ATK SQ, ATK MV and RE PRT predicates. This position is the same as
Fig. 5 after one exchange (NxP, QxN). A call to ATK SQ on QB7 (SQ)
yields the fact that the opponent king protects his queen. In the first step to
determine if the king as protector can be drawn away, ATK MV is used.
IF (ATK MV (SQ, MV LST, NM MVS))~ (6)
$
ATK MV is FALSE only if the number of moves, NM MVS is zero. MV
LST is a 2-dimensional list containing the origin and destination square of
each move attacking SQ. Thus for the position of Fig. 9(a), MV LST would
contain the bishop move indicated by the arrow (B-KR7). A second call to

"13 -K }( -X }(
-Q - p / , "B "Q

(a) (b)
FIG. 9. Illustrationof drawingoff protecting pieces.
A MINIMAL CHESS PLAYER 153

ATK MV would yield the information that the king cannot move to reprotect
the opponent queen as it could if either the bishop or the pawn were absent.
ATK MV is a very general program, whose use has only begun.
For the situation of Fig. 9(b) the opponent queen could reprotect the rook
simply by moving back. Since such a move would not be considered an ATK
MV a call to RE PRT is needed.
IF (RE PRT (SQ ATKD, SQ PRTG, MV LST, NM))--, (7)

The arguments would be the rook square and the queen square followed by the
list of reprotecting moves and the number of them.
Another valuable predicate is SF MV SQ. For example of Fig. 10 it could

~ ~---Q

N ~ B

FIG. 10. The use of SF MV SQ.

be discovered that the indicated pawn move protects the pawn while the
queen move still leaves it EN PRIS.
IF (SF MV SQ (SQ FM, SQ TO, SQ PRT))~ (8)
$
SF MV SQ merely makes the corresponding move, calls EN PRIS on the
square being protected and unmakes the move to restore the minimal game
board.
X -K ~- * -K
-p -p -p -~ .

R
N ~ Q ~ ~ ~ ~

(a) (b)
FIG. 11. Illustration of the M T T H R T predicate.

The mating threat predicate, is illustrated in equation (9) and correspond-


ing examples are shown in Fig. 11. A mating threat is defined as a move which
leads to mate if the opponent's first reply is suppressed. A check is thus an
obvious mating threat.
154 E . W . KOZDROWICKI, J. S. LICWlNKO AND D. W. COOPER

IF (MT THRT (MTNG SQ, SP PC SQ))~ (9)

To determine ifa move such as N-KB5 is a mating threat the move is actually
made on the minimal game board, and the square attacked is proposed as the
mating square (MTNG SQ) and given as input for the first argument. The
MR THRT program determines if the proposed MTNG SQ is in the king
sector, invokes ATK SQ for the proposed mating square and for each move in
turn determines if the potential mating move leaves the moving piece EN
PRIS, if the king is left EN PRIS and if a king run is possible. The second
argument (SP PC SQ) returns the square on which the piece supporting the
mate threat resides, i.e. the queen square in Fig. 1l(a). Figure 1l(b) illustrates
a case where the mating square returned is not the one proposed. It is apparent
from Fig. ll(b) that the new mating square must be created by ATK MV
(Proposed KN7, returned KR4).
The interpose function shown in equation (10) yields a set of moves that
constitute interposes between 2 squares. The squares are normally the square
of the mating piece (or checking piece), SP PC SQ and the mating square (or
king square), MTNG SQ.
IF (INT POS (MT PC sO, MTNG sO, MV LST, NM))-~ (10)

Figure 12 indicates 3 interposing moves that relieve the corresponding mating


threat.
•~ -K
-P -I~ -P

N ~

~ Q ~

FIG. 12. Moves to relieve a mating threat; use of I N T POS.

Another important predicate is PAS PWN (passed pawn) which examines


the 2 files adjacent to a pawn to determine if there are obstructing opponent
pawns. It is also used to discover isolated pawns. The described predicates
form a reasonably complete logical command structure. Some functions that
return numerical values follow.
• IF (MV DIRC (SQ TO - SQ EM) . E Q . 1 3 ) - , (11)

For equation (11) if SQ TO were 118 (KRS) and SQ FM were 27 (QR1)


then MV DIRC would be returned with the value of 13. Any knight directions
A MINIMAL CHESS PLAYER 155

are returned as zero, i.e. actually knight directions are orthogonal and thus are
unimportant.
Since a mating threat is such a frequent occurrence in chess it is desirable
to have a function to yield the relative strength of the mate threat, i.e. a mate
threat score.
IF (MT TH SC (MTNG SQ, SP PC SQ) .LT. 100000)~ (12)
$
The arguments of MT TH SC are the same as MT T H R T and normally
passed from MT THRT. If there is no way for the opponent to answer the
threat, MT TH SC is returned as 100,000. Successively lower arbitrary scores
are returned if the opponent can best answer the threat by (1) an unsafe
move, (2) a king run (3) protecting the mating square, (4) by interposing a
piece, or (5) by castling. Similar scores (with exception of cases 3 and 5) are
returned for checking moves as illustrated in equation (13).
IF (CHK SC ( C H K G SQ) .EQ. 100000)--, (13)

Forks: The Complex Fork

A most fundamental strategy in chess is to attempt to achieve two-way


threats or forks. The most common fork is illustrated in Fig. 13(a) where one
piece attacks 2 others simultaneously. Figure 13(b) illustrates a threat to fork
while Fig. 13(c) illustrates a second order fork whose occurrence is infre-
quent. The complex fork of Fig. 13(d) however is of very frequent occurrence.
It can be noted that pawns prevent the queen from protecting the forking
square. This fact can be detected by ATK MV. The complex fork of Fig. 13(e)
has profound effect on openings when look-ahead procedure or search is
used. Figure 13(f) illustrates a frequently occurring first order fork where
a mating threat constitutes one fork arm. ATK MV must be used to deter-
mine if the attacked piece can move to protect the mating square thus voiding
the fork. Discovered attacks that win material, such as illustrated in Fig. 13(g),
are also recorded as forks. The avoidance of the possible false fork by the
queen, as illustrated in Figure 13(h), requires considerable extra program and
commands considerable execution time.
The FORKprogram takes about 1200 FORTRANstatements and directly dis-
covers most moves that gain material through a two-way threat, the second
order fork being one exception. The FORK program is called for each legal
move of a minimal game as shown in Fig. 2. As is partially illustrated in
Fig. 13(c) the use of the forking program is equivalent to carrying out a 3-level
156 E.w. KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

(ply) exhaustive search ignoring o f course all o p p o n e n t responses. These


could be referred to as special purpose search trees. FORK also discovers the
creation o f pins and X-ray attacks and returns 46 c o m p o n e n t scores (mostly
strategical) the sum o f which is the score for a move.

(o)
(b)

-R * -P * -P * -P

(c)

-R,,..~ * _~.,--K ~ -R *-B-Q-K * -R -K


,--,~, -p , -p-~p'-p.J~'. -Q .p -p

X X /X )t/" X X

(e) (f)

X\X ~ X X
I
I

(g) Q
(h)
FIG. 13. Forks and threats. (a) First-order fork. (b)First-order threat to fork. (c) Second-
order fork: a virtual non-occurrence. (d) Complex fork. (e) A complex fork (N-N5) which
has profound effect on openings. (f) A first-order fork with a mating threat and a direct
attack. (g) A king-queen fork. (h) A false fork.

Sacrificial Combinations and the Fisher Set


The example of Fig. 14 illustrates h o w sacrificial moves must be scored and
the m e a n i n g o f the "Fisher Set". The score on a sacrificial move, such as
A MINIMAL CHESS PLAYER 157

NxP, must reflect the expected resultant gain (this is not necessarily true when
look ahead is used). The terminology of the Fisher set arose out of occur-
rences at tournaments where spectators would repeatedly try to predict the
moves of the American Grandmaster, Bobby Fisher. It has been rumored that
his selected move was always the one least predicted. Apparently the best
moves always tend to receive the lowest score in the minds of lesser players.
Once a move is scored into the Fisher set it cannot be retrieved, even with
tree searching or look-ahead procedure. The Fisher set shall remain a prob-
lem to automated chess until perfect play is achieved!

-p
-N

-N -R ~ N
* * P
Q *
(a)

NXP I000 l
___--__. . . . ._~__. j~Sacrificialset

NXN 0 ]
____~_.......... .-- j~ Regular set

QX.~N -6000 } Fisher set

(b)
FIo. 14. Sacrificialcombinations and the Fisher set.

When playing a minimal game all legal moves are considered in sequence
and scored by the forking program. Next, good sacrificial moves are proposed
by the E X C H N G program and the corresponding moves, already loaded into
the minimal game set, have their scores modified. The E X C H N G program
could produce non-sacrificial moves and sacrificial moves could be screened
by SAFE SQ. Next an arbitrary number of the highest scored branches
(moves) are accepted as the minimal game. All remaining moves are thus con-
demned to the Fisher set and erased. The Fisher set is a fuzzy set. The Fisher
set has little consequence until multiple minimal games or look-ahead pro-
cedure is used. There it has profound effect on selective searching and must
be clearly defined. (Further detail appears in Kozdrowick & Cooper e,
1971).
158 Z . W . KOZDROWICKI, J. S. LICW1NKO AND D. W. COOPER

Exchanges Which Remove Defense


An exchange that removes a defense is illustrated in Fig. 14(a); NxP. Upon
fixing the exchange board, all opponent pieces under attack are put on an
exchange list. Everytime an exchange such as NxP, NxN is perpetrated an
EN PRIS test is made for every piece on the exchange list. If any piece in-
volved in the exchange (e.g. NxP, NxN) is X-rayed or pinned the corre-
sponding new piece under attack is temporarily added to the exchange list.
Though this looks like brute force, the exchange list is small (usually 3 or 4)
and is screened rapidly.

Manoeuverable Opponent Tactical Units


A fundamental game strategy is to "draw" tactical units into a desirable
position. In the illustration of Fig. 15 the knight capturing a pawn is an
initial sacrifice followed by a winning queen fork. For program operation,
after perpetrating the exchange NxP, KxN, a call to ATK MV would yield
the queen attack. Next the discovered move, Q-KB4, would be scored by the
FORK program thus discovering the king-rook fork. In addition after each
exchange ATK MV is also called directly on the king and corresponding

-R-N *-O-K~w *-R


w w * -P ~'-P\ w

~( w ~( w w w N *
~( X ~( P .W I( .W .W
W W W w P -~ ~ w

w ~ w Q'/w w ~( ,Ix-

FIG. 15. A fundamental concept is to draw tactical units into desirable position.

moves are scored by FORK. The king attack feature alone results in the
solution of 4 of Reinfeld's (1955) puzzles.
The third algorithm for discovering sacrificial moves is that described in
conjunction with Fig. 9. I t involves drawing off a protecting tactical unit by
attacking it directly. The 3 methods are referred to in Fig. 16 as E-F-D;
exchange, fork and draw. Though usually true it is not necessary that E-F-D
results in proposing sacrificial moves.

The Alpha-beta Algorithm: Simulation of Human Thought Processes


Experts have posed a dilemma when they suggested that game-playing pro-
grams use the alpha-beta algorithm effectively yet human checker or chess
A MINIMALCHESSPLAYER 159

masters, when questioned, claimed they did not use it in any conceivable way.
Figure 16 illustrates an exhaustive low-level alpha-beta search which does
indeed simulate human thought (which according to local prejudice is an
acceptance criteria). Figure 16(a) gives an example exchange situation with 3
attacking and 3 protecting units. It is desirable to try E - F - D or exchange, fork,
draw procedures after all possible combinations of capture-recapture pairs.
-B )~ -K

B/.x.
6
(a)

E -F-D

E-F-D

E-F-D
BxB E_F.D~ - ~ ' ~-
E-F-D

BxP

tQxB

[KxB
Low level alpha beta trimming

&--- --

(b)
FIG. 16. The alpha-beta dilemmai a specializedexhaustivesearch tree. (a) An exchange.
(b) Exhaustive search for a singlefeature.

The search tree shown in Fig, 16(b) represents an exhaustive search for a
single feature centered about a single exchange. As illustrated in Fig. 16(b)
the exchange pair, BxP, BxB is tried followed by E-F-D. If there is no E - F - D
success further exchange pairs and E - F - D are tried. In the event that all 5
E-F-D's, as shown in Fig. 16(b), have no success the opponent has success-
fully answered the threat of BxP. There is no point in testing the other
opponent replies of QxB or KxB. (This simple fact constitutes the well known
160 E . W . KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

alpha-beta algorithm). Similarly some fourth level branches are also term-
inated. The asterisk (*) indicates that further growth from that branch is
not to be continued. When applied this way such a low level alpha beta
pruningt algorithm is in accord with human thought. It is, in fact, the appli-
cation that makes the accordance. The total tree of F i g 16(b) requires only
15 E - F - D ' s on the condition it fails to show results on all E - F - D ' s (only
5 are shown, i.e. NxP or QxP sequences are not shown). This procedure is
carried out for all possible exchanges yet the E - F - D ' s per minimal game re-
main small. Although the tree of Fig. 16(b) may appear as if look-ahead
procedure is employed it only results in occasional moves to be inserted
into the minimal game set of Fig. 14(b).

Multiple Minimal Games: Look-ahead Procedure


The sample search tree of Fig. 17 illustrates how 5 minimal games can
N-KB3
129

P-K4

N-KB5
126

P-Q4

P-Q3
108

FIG. 17. Five minimal games discriminate move choice.

discriminate 2 moves that otherwise had identical scores in Fig. 2. To produce


the tree of Fig. 17, the move, P - K 4 is actually made on the minimal game
board (Fig. 3) and a minimal game is played for the opponent, etc. The score
of 129 represents the cumulative value of the machine transformations
(P-K4 plus N-KB3) minus the value of the opponent's best reply (in a zero
sum game his gain is the machine's loss). Note that each minimal game includes
t Cooper (1969) has referred to such procedure as selective search since no part of the
tree is physically removed but its growth merely directed. COKOIII actually uses a proce-
dure where growth is physically removed and redirected growth continues. Such pruning is
true tree pruning precisely analogous to the pruning of "trees in an orchard".
A MINIMAL CHESS PLAYER 161

a new pre-analysis (earlier versions of the program actually stored pinning


information as part of the move transformation and actually transformed the
pinboard to correspond to the new minimal game). Clearly if there were no
limit of time or memory a sufficient number of minimal games would insure
perfect play; something which no-one has yet seen for chess. To exhaust three
levels, however, might average 1000 minimal games (~302), approximately
20 times a reasonable upper limit on an IBM-7044.
The entire chess program development has been concerned with only the
minimal game. Whenever look ahead was used the tree searching language
(TSL) (Kozdrowicki, 1968a), automatically guided the selective search. No
true tree pruning was used with the current program but only selective search.
Using TSL, search is always directed along the path calculated as the most
likely to yield success. As there can never be enough resources to search the
Fisher set it is never loaded into the tree. Because of exponential growth the
Fisher set is progressively larger with greater depth in the tree. At greater
depths the Fisher set is defined as all but 2 or 3 moves. A strategical search
tree, like the one of Fig. 17, is a progressive widening deepening tree. Tactical
search trees are created depth first and are composed of strategical subtrees.

Tactical Search Trees with Depth Specification


For the example of Fig. 5 the EXCHNG program expects to win a pawn by
playing NxP. Since other unforeseen circumstances, such as an opponent's
mate threat, could arise it is desirable to request that search be carried out 4
more ply levels. At an early stage in development EXCHNG had mistakenly
assumed that NxP would result in winning the queen as shown in Fig. 9(a).
With further tactical search this mistake was corrected at the fifth ply level as
shown in Fig. 18(a). This procedure allows the loading of a risky move
with an unrealistic score knowing that it will be later corrected if wrong. If
false scores appear deeper in the tree, however, they represent unrecoverable
false threats. Suppose the error of Fig. 18(a) appeared at the second ply level
as shown in Fig. 18(b). The queen move, Q-QN7, for example, may have been
the only way to defend a knight but would be avoided because of the false
threat of queen loss. Virtually, no quantity of search could recover such an
error (unless the ply 1 and ply 2 Fisher sets were made unrealistically large
and the corresponding minimal games very small). Figure 18(c) shows an
estimate of probable scores for a move transformation. The scores are discrete
thousands for the expected gain or loss of tactical units with a superimposed
smaller strategical score which is near Gaussian.
Anytime a large tactical score predominates this causes the production of
162 E . W . KOZDROWICKI, J. S. LICWINKO AND D. W. COOPER

a depth first, tactical subtree which itself consists of strategical subtrees.


Figure 17 shows a strategical subtree while Fig. 18(a) shows a tactical sub-
tree. The growth of a strategical subtree is guided by the Gaussian scores of
one of the envelopes shown in Fig. 18(e).

I000
I I correctedscore
OTHER I
NxP 4000 ]
// lO,N ,~ . . . . . . . . . . . . . . . . . . . . . . . 4000
Z-Erroneousscore
(o)

Nxp -4000}
Q-QN7 l

-3000]
[---5000~ Loss of a rook
I -3oooj
: 1
(bl

{c)

FIG. 18. The false score problem. (a) First ply erroneous scores on risky moves may be
corrected by look ahead. (b) False scores representing excessive threat can redirect and
misguide the search. (c) Estimate of probable scores for a move transformation; tactical
plus strategic scores.

The MATER Tree

Though most machines play p o o r end game it is really in end game where
there is much opportunity to take advantage of the machine's brute force
capability. Originally this p r o g r a m produced 2 trees per move. I f the MATER
tree did not produce mate it was discarded and the regular tree made the
move selection. An early achievement was a mate in 9 (18-ply) puzzle by a
series o f checks.
A MINIMAL CHESS PLAYER 163

The MATER tree, as illustrated in Fig. 19 is a purely offensive venture.


Each machine minimal game, with exception of the first, consists solely of
checking moves and mating threats. The E X C H N G program is used to load
some special moves at ply 1. Each move is scored by FORKwhich in turn uses
C H K SC or M T T H SC. On the opponent ply all replies to the check or
mate threat are scored and loaded. Any branch achieving mate is given a
score of 100,000 while if the machine has no mate threat or check a dummy
branch with - 100,000 is loaded (equivalent to defeat for the desired goal).
If the opponent has too many replies to a mating threat a dummy branch
with - 100,000 is also loaded (defeated by the opponent by virtue of sheer
volume of replies). A completed tree that does not achieve mate is enveloped
with - 100,000 branches.
I00000

MT [ -I00000
~
CH
I CH

"IO0000=MATE
,IO0000=MATE

E-F-D -I00000

FIG. 19. A MATER tree. M T = n o n - c h e c k i n g m a t e t h r e a t ; C H = c h e c k ; E - F - D = ex-


c h a n g e - f o r k - d r a w ; * = g r o w t h t e r m i n a t e d ; - 1 0 0 0 0 0 = n o n - m a t i n g sequence.

Although sacrificial moves are loaded into the tree, the MATER tree is
plagued with exponential growth and a great deal of selection, through
scoring is necessary. Frequently the MATER tree discovers sequences that
win material or gain strategical position. For the minimal game all the moves
selected are determinable on the basis of an algorithm. The MATER tree,
however, frequently selects moves for which it seems indeed "impossible" to
discover a minimal game algorithm. After further experimentation and
development this MATERprocess will be combined with the regular tree for
COKO III.

Conclusion
It is felt that in order to create a good chess program there is no substitute
for a direct analysis of the problem and implementation of fundamental
164 E. W. KOZDROWlCKI, J. S. LICWlNKO AND D. W. COOPER

algorithms. When COKOIiI played in the ACM computer chess champion-


ship (29 August 1970) under close competition, the algorithms it did not have
were A T K MV, MT THRT, MT TH SC, CHK SC, INT POS and RE PRT.
Without ATK MV and RE PRT, COKO III could not directly, at least,
achieve the puzzle of Figs 5 or 9. Also the alpha-beta indexing and a bulk of
the EXCHNG program was not present. Furthermore COKO'SFORKprogram
did not detect complex forks nor first order forks involving mating threats.
Both complex forks and mate threat forks require the use of ATK MV as
illustrated in Fig. 13(d). COKOdid play well in the tournament which can be
readily seen from the tournament record which is available upon request.
The quality of COKO'S play was the result of the use of tactical control
moves or chess logistics to guide the multiple minimal game search.
It is hoped that the incorporation of the above features along with other
additions and modifications will help to improve COKO'Slevel of play by the
time of the 1971 computer chess championship in Chicago.
The algorithms described herein are tried and tested. Though they appear
rather obvious and perhaps trivial as described here their discovery involved
a great deal of trial and error and reformulation of ideas. The program is
entirely in FORTRANwhich is the sole language suitable for the job. This is
true in particular because due to circumstances the program or versions of it
have run on IBM, PDP, Univac, Burroughs and CDC machinery. It is felt
here that it would be difficult to progress much beyond the B class of play with
the 24K memory limitation of the IBM-7044. Modern machines indicate no
inherent limit yet. Opinion varies greatly as to the difficulty involved in pass-
ing to Master play and beyond. Little over one year ago the puzzle of Fig. 5
was viewed here as virtually impossible. Now it requires less than 2 sec.
(minimal game--IBM-7044) for solution in generality. It was also found that
the equivalent or near equivalent of book move openings can be discovered
on the basis of principle and can be discovered rapidly, compared with mid or
end game play.

References
BAYLOR,G. W. & SIMON,H. A. (1966). A chess mating combinations program,
Proc.-Spring Joint Computer Conf., pp. 431--47.
BELL,A. G. (1970). How to program a computer to play legal chess. Computer J.
13, no. 2.
BOTVINNIK, M. M. (1969). Computers Chess and Long-range Planning. New York:
Springer Verlag.
COOPER, D. W. (1969). Heuristic Tree Searching in the Game of Chess, Working
paper,
A MINIMALCHESSPLAYER 165

DE GROOT, A. (1966). Thought and Choice in Chess. New York: Basic Books.
F•IGENBAUM, E. A. & F~.LDMAN, J. (Eds) (1963). Computers and Thought. New
York: McGraw-Hill, Inc.
FINE, R. (1967). The psychology of the chess player. New York: Dover.
GARDNER, M. (1959). Mathematical games. ScL Am. 206, 138.
Gooo, I. J. (1967). A five-year plan for automatic chess. Machine Intelligence.
Edinburgh: Oliver and Boyd.
GREENBLATT, R. D., EASTLAI~E,D. E. & CROCKER, S. D. (1967). The Greenblatt
chess program. AFIPS Conf. Proc. Washington, D.C. : Thompson.
HUBERMAN, B. J. (1968). A program to play chess end games, Ph.D. Thesis, Stan-
ford University, 1968 (also Technical Report CS106 August).
KozoRowicr~, E. W. (1968a). A practical application of machine learning: use of
learning in an interpreter for a tree searching language. Proc. LE.E.E. Systems
Science and Cybernetics Conf., pp. 250-7. San Francisco, California.
KOZOROWICKI, E. W. (1968b). An adaptive tree pruning system: a language for
programming heuristic tree searches. Proc. A CM Conf.
KOZDROWICKI,E. W. & COOWR, D. W. (1971). Coko-III: The Cooper-Koz Chess
Program, Comm. ACM (To be published).
REINrELD, F. (1955). Improving Your Chess. New York: Barnes and Noble, Inc.
SAMUEL,A. L. (1967). Some studies in machine learning using the game of checker.
II-Recent Progress, I B M Journal, 11 (6) November.
SCOTT, J. J. (1969). A chess playing program. Machine Intelligence IV. New York:
Elsevier.
SHANNON, C. E. (1950). Programming a digital computer for playing chess.
Phil. Mag. 41, 256.

You might also like