Chess End Game Pattern
Chess End Game Pattern
knowledge
I. Bratko*, D. Kopec and D. Michie
Machine Intelligence Research Unit, University of Edinburgh, Hope Park Square, Meadow
Lane, Edinburgh EH8 9NW
—Knowledge v. search:
1. Rules of chess: don't get mated! Up to 24 moves before losing knight plus up to 16 moves before
being mated:
« 80 ply
2. Additional advice: don't lose knight!
From chess ~ 48 ply
programmer's <
point of view: 3. Additionally: keep king and knight together!
Necessary, and probably sufficient, lookahead is:
10 ply
Fig. 4 Salient features of the KNKR end-game. The size of the total problem space, after reduction by disregarding symmetric cases, lies be-
tween 3 x 106 and 4 x 106. The boxedfiguresshow the depth of search necessary, for the program's given state of knowledge, to select
a draw-preserving move. Ply = half move
The KNKR game of king and knight. A correct treatment of such positions
In further experiments with the AL1 system, the king + knight with king and knight separated would require additional
v. king + rook ending (KNKR) was used as an experimental knowledge.
domain that is not trivial from the human expert's point The upper table of Fig. 5 specifies four rules (CR, R l , R2, ER)
of view. Fig. 4 presents some data that illustrate the difficulty by the 'Yes, No, Don't-care' column patterns. These patterns
of this end-game. The first two items, chess books and tourna- refer to POP-2 predicates flanking the table:
ment games, give some insight into the difficulty from the OKEDGE —our king on the edge;
chessplayer's point of view. The difficulty from the pro-
grammer's point of view is illustrated by the third item which OKONSEP —our king and our knight separated (distance
indicates the relationship between the amount of knowledge greater than 4 in king moves);
possessed by the program and the depth of game-tree search CORNCASE—corner case, a special 'classical' situation
required for correct play. (e.g. Fine, 1964) with the king in the corner,
The KNKR ending is usually drawn, but under certain requiring exceptional treatment.
circumstances the stronger side (the one with the rook) can The current chess position is matched against the rule patterns
win. A winning procedure, when there is one, consists usually from left to right. As soon as a match is found the correspond-
of combining three basic principles (Fine, 1964): ing rule is applied. For example, if the position does not
1. Create mating threats. satisfy the CORNCASE condition and the king is on the edge
and the king and knight are not separated, then rule R2 matches
2. Force separation of king and knight. the position and the list of pieces of advice 1, 5, 6, 7, 8, 12 is
3. Stalemate and capture the knight. applied. The pieces of advice are defined by the lower table
The KNKR advice table must cope with the above threats in Fig. 5. Consider for example Advice no. 1 called
and thus preserve a draw for the weaker side when starting KiLLROOK. The better-goal to be satisfied in them-to-move
from a theoretically drawn position (in all such, the king and positions specified with this piece of advice is TRDEAD
knight are not separated). The table, shown in Fig. 5, contains (their rook dead). As already stated, depth of search is limited
enough knowledge (according to experimental tests) both to to 4 ply, and to improve search efficiency we also specify
preserve the draw in positions with king and knight sufficiently holding-goals NOT ONLOST (not our knight lost without
close together and to maintain the degree of centrality of the compensation) and TRDEAD OR CHECK (their rook dead
weaker side's king while searching to a depth of at most 4 ply or their king in check). By this the search is limited to con-
(half-moves). Centralisation of the king is important to the sideration of immediate captures and checking-moves, which
weaker side because mating threats can occur only when the amounts to looking for ways of forking their king and rook.
king is on the edge. Therefore when the king is on the edge This tactic is indicated by the fact that there is no other way
the defence becomes considerably more difficult. The KNKR to force capture of the rook.
table thus actually conserves the degree of easiness of defence. When testing the correctness of the table a variety of players,
When the king is started on the edge and not separated from two of National Master strength (rated over 2300 on the
the knight, for those positions which are theoretically drawn, international scale), have engaged the system in play for a total
the table preserves the draw in all cases tested. Recently elapsed time of more than 10 hours (150 moves on each side,
a class of specially tricky positions has been discovered by starting from different positions). No absolute way exists of
D. Kopec, not previously known in chess literature, where the proving correctness for all possible positions short of either
only correct defence requires a counter-intuitive separation (a) exhaustive checking through the total space of 3-4 million
3SCL
OND
O
DND
NDL
NDL
Q i-l
EAD
\FE2
Z
Z
Q
1 Z Q Q
s Q
g
o
H
O
00
zO
Q
a;
H
O
P-I
^4
O
U
&4
O
O
^4
O
6
O
O
zo
H
z
s
o z z z o
1: KILLROOK — Y (Y) Y Y
2: HOLD1 (Y) Y Y — Y Y Y Y Y (Y) Y
3: HOLD2 (Y) Y Y — Y Y — Y Y (Y) —
4: HOLD3 Y Y Y — Y — Y Y Y 00 —
5: HOLDEDG1 Y Y Y — Y — Y Y — (Y) —
6: HOLDEDG2 Y Y Y — — — Y — — Y —
o
f1 7: HOLDEDG3 Y Y Y — — — — Y — (Y) —
8: HOLDEDG4 Y Y Y — — — — — — Y —
9: CORNCASE 00 (Y) (Y) — — — — — — — —
10: APPROKON Y — Y Y Y — — — — — — — —
11: SURVIVE 1 Y Y Y
12: SURVIVE2 — — Y —
Fig. 5 The upper table is the KNKR Advice Table as written and tested. The integer lists index a repertoire of 12 pieces of advice. These are
shown in the lower table expanded in the form of calls to indicated subsets of the 14 goal predicates listed along the top. 'Y's enclosed in
brackets are logically implied by the other predicates selected in the same row. The symbols in parentheses (utm) and (ttm) mean 'us-to-
move' and 'them-to-move' respectively
positions or (b) formal proof. ALl's tabular format offers forward search. As an annotation on this last remark, we
simplifications which make the latter an attractive topic for append results, kindly supplied by D. Slate, of having the
study. leading US tournament program CHESS 4.5 play the KNKR
When playing the KNKR ending on the PDP-10 computer the game against an expert opponent from selected starting
present implementation of AL1 spends on average about one positions.
minute of computer time per move, mostly due to the com-
parative inefficiency of the forcing-tree generating routine. Performance of CHESS 4.5 tournament program with KNKR
The program examines about 10 nodes in the game-tree per Tournament programs have the aim of playing reasonably
second. When run on comparable machines, other chess- well, but not of course with guaranteed correctness, in all
playing programs, e.g. CHESS 4.5 (Slate and Atkin, 1977) phases of the game: opening, mid-game, and ending. Such
or MASTER (Birmingham and Kent, 1977) examine at least 'general' chess programs cannot pay much attention to specific
a few hundred positions per second. A new version, AL2, features of different position-types. Rather these programs
is under construction with an eye to increased run-time effici- embody generalised chess principles, or heuristics, hopefully
ency, among other improvements. But considering ALl's applicable to the large majority of possible positions. Lack of
efficiency from the point of view of programmer productivity, position-type specific knowledge is to some extent balanced
these experiments gave evidence of great savings. Table writing by deep lookahead, facilitated by fast game-tree search routines,
and check-out for KNKR occupied one of us (I.B.) for less efficient tree-pruning, efficient coding, and fast hardware.
than six weeks. We doubt whether correct play, especially if CHESS 4.5 was required to defend the weaker side of KNKR
'centrality preservation' is to be included, could be program- against a human opponent rated just over 2000 on the US
med using standard methods in less than a substantial multiple Chess Federation scale, i.e. an 'expert'. The program ran on a
of this figure other than by promoting large proliferations of CDC 6400 machine, on which it was able to win the 1976
References
BERLINER, H. (1974). Chess as problem solving: the development of a tactics analyser, Ph.D. Thesis. Pittsburgh: Carnegie-Mellon University.
BIRMINGHAM, J. A. and KENT, P. (1977). Tree-searching and tree-pruning techniques, Advances in Computer Chess 1 (ed. M. R. B. Clarke),
pp. 89-107, Edinburgh: Edinburgh University Press.
BRAMER, M. A. (1977). Representation of knowledge for chess endgames: towards a self-improving system, Ph.D. Thesis, Milton Keynes:
The Open University.
BRATKO, I. (1978). Proving properties of strategies expressed in the AL1 assertional language, (Inf. Proc. Letters, forthcoming.)
BRATKO, I. MICHIE, D. et. al. (1978). A representation for pattern-knowledge in chess end-games, Advances in Computer Chess 2, (ed. M. R.
B., Clarke, forthcoming).
CLARKE, M. R. B. (1977). A quantitative study of king and pawn against king, Advances in Computer Chess J (ed. M. R. B. Clarke)
pp. 108-118, Edinburgh: Edinburgh University Press.
FINE, R. (1964). Basic Chess Endings, New York: David McKay Company.
HUBERMAN, B. J. (1968). A program to play chess end games, Technical report no. CS106, Stanford University: Computer Science Depart-
ment.
KERES, P. (1974). Practical Chess Endings, London: Batsford Ltd.
KMOCH, H. (1959). Pawn Power, New York: David McKay Company.
KNUTH, D. (1976). Mathematics and computer science: coping withfiniteness,Technical report STAN-CS-76-541, Stanford: Department of
Computer Science.
MCCARTHY, J. (1959). Programs with common sense, Mechanisation of Thought Processes 1, London: HMSO.
MICHIE, D. (1976). An advice-taking system for computer chess, Computer Bulletin, Series 2, No. 10, pp. 12-14.
SHANNON, C. E. (1950). Programming a computer for playing chess, Phil. Mag, (Lond.), 7th ser. 41, pp. 256-75.
SLATE, D. J. and ATKIN, L. R. (1977). CHESS 4.5—the Northwestern University chess program, Chess Skill in Man and Machine (ed. P. Frey),
pp. 82-118, New York: Springer Verlag.
TAN, S. T. (1977). Describing pawn structures, Advances in Computer Chess 1 (ed. M. R. B. Clarke), pp. 74-88, Edinburgh: Edinburgh
University Press.
ZUIDEMA, C. (1974). Chess, how to program the exceptions? Afdeling Informatica, IW21/74, Amsterdam: Mathematisch Centrum.