README: Documentation text file for the Chess In Lisp foundation
Comments to the author: email@example.com (Steven J. Edwards)
The CIL (Chess In Lisp) foundation is a Common Lisp implementaion of
all the core functions needed for development of chess applications.
The main purpose of the CIL project is to get AI researchers
interested in using Lisp to work in the chess domain.
Since the seminal work of Claude Shannon and Alan Turing from nearly a
half century ago, numerous artifical intelligence researchers have
utilized the chess domain as a vehicle for testing their ideas via
program implementations. About a decade after Shannon and Turing,
John McCarthy invented the Lisp language and it has remained to this
day as the programming language of choice for AI applications. Now,
the interesting observation here is that there have been no serious AI
full-domain chess applications in Lisp. While there have been a few
projects in Lisp that worked in restricted subdomains of chess (the
PARADISE project by David Wilkins in 1980 is an example), no one has
developed a full domain chess playing program in Lisp that uses
traditional AI techniques. There have been a few student chess
programs written in Lisp, but none are known to use anything much
beyond the traditional alpha/beta minimax search.
--- The Central Question
Why is it that AI workers haven't used Lisp to attack such an inviting
target as chess?
There are several answers. First, common industrial production
languages like C/C++ and Pascal are easier than Lisp for some and
support for these languages is more common than it is for Lisp.
Second, work in the chess domain has shown that the simple alpha/beta
search technique produces a high standard of performance and this
level has increased through the years as faster hardware has become
available; for those who value performance above generality, it is
difficult to find motivation for alternative approaches. Third, Lisp
has traditionally been implemented as an interpreted language and its
relative slowness is considered by some as a handicap for real time
applications such as tournament chess. Fourth, chess programming
requires a significant amount of low level detail work for move
generation and position operations and this has deterred those with
limited time resources or with limited patience (or skill) with
handling issues not directly related to higher level AI topics.
--- Things Have Changed
There is now a well-recognized and implemented standard for Lisp
(Common Lisp) with support for a variety of platforms. The near
omnipresent alpha/beta search has probably been exploited near to its
limits and so chess performance levels vary not so much on
implementation technique but rather upon how much money one has for
hardware. Public exhibitions of world class levels of chess playing
may impress the masses, but they contribute little (if any) to
artificial intelligence in general. Serious AI workers have, with
justification, criticized chess programmers as claiming AI status only
because of the performace demonstrated and not because of the
methodology employed. The chess programmers have responded mostly by
disclaiming AI status. But a better, or at least a more interesting
response would be to re-examine the tools of AI theory and programming
and start applying them to the chess domain. So, now we have the CIL
project to help stimulate real AI work in the chess domain by making
it easier to utilize well-known Lisp AI techinques (e.g., machine
learning, generalized search techniques, pattern recognition, and
--- Project status
The current version is a work in progress and is being released so
that other researchers may have an opportunity to see the direction of
the effort and to elicit feedback on future development.
The current version includes a full set of chess definitions, move
generation, move execution/retraction, position status determination,
formatted move I/O using SAN (Standard Algebraic Notation), and
several programming examples. It is not intended as an example of
traditional Lisp programming techniques; instead, it is intended as an
easy to use and portable collection of tools designed to facilitate
the development of applications that do use traditional Lisp
--- Data Representation
The program uses the bitboard technique that employs 64 element simple
bit vectors for representing boolean properties of a chessboard. The
various bitboards and arrays of bitboards are documented among the
global constants and global variables within the source. At all
times, the processing core keeps track of:
1) Vacant/occupied squares (bitboard *ammbb*)
2) Occupied by color squares (bitboard vector *c0bbv*; indexed by
color, two elements)
3) Occupied by color-piece type squares (bitboard vector *cpbbv*;
indexed by color-piece type, 12 elements)
4) Attacked by color squares (bitboard vector *acbbv*; indexed by
color, two elements)
5) Attacks to a square by either color (bitboard vector *atbbv*;
indexed by square, 64 elements)
6) Attacks from a square (bitboard vector *afbbv*; indexed by square,
There are also a number of constant bitboards: the null bitboard,
edges, king moves, knight moves, intersquare paths, etc.
Colors are repesented as 0 for white and 1 for black. Pieces are
represented as 0 for a pawn, 1 for a knight, 2 for a bishop, 3 for a
rook, 4 for a queen, and 5 for a king. Color-pieces are represented
as ((color * 6) + piece); a white pawn is 0, a white king is 5, a
black pawn is 6, and a black king is 11. A vacant square color-piece
is a 12.
Ranks are represented with 0 (rank one) to 7 (rank eight) and files
are represented with 0 (file a) to 7 (file h). Each square is
represented as ((file + (rank * 8)), so square a1 is 0, square h1 is
7, square a8 is 56, and square h8 is 63.
The global variable *board* is an array of 64 integers, each with the
value corresponding to the occupying color-piece. The status
environment is composed of the active color (*actc*), the passive
color (*pasc*), the castling availability (*cast*), the en passant
target square (*epsq*), the halfmove clock (*hmvc*), and the fullmove
number (*fmvn*). The board and the status environment (except the
passive color) can be displayed with the "ui-dvfe" user interface
function (display value: Forsyth-Edwards notation).
The current version was developed using Macintosh Common Lisp provided
by Digitool. It should run on any Common Lisp conformant platform.
Unfortunately, the code appears to trigger a garbage collection bug in
GNU Common Lisp running on the Linux operating system. Linux/GCL
workers are invited to diagnose and fix the problem.
The CIL Lisp source is entirely contained in the text file cil.lsp and
is organized with global constants appearing first, global variables
appearing second, various core functions appearing third, and some
programming examples appearing last. A number of user interface
functions are provided; each of these have names of the form "ui-XXXX"
where the "XXXX" is a command mnemonic. Note: the function "ui-init"
must be called prior to any other function; it performs general
initialization and this is required before further operations.
The experimenter is invited to work through the source code and
commentary for further details of operation.
--- Future Work
Well, there are a lot of things for future work. Here are some in
1) Improved external documentation.
2) Improved internal documentation.
3) Lisp packaging.
4) More programming examples.
5) More support for data exchange standards; these include FEN input,
EPD I/O, and PGN I/O.
And here are some to come later, perhaps much later:
1) Development of a general pattern facility that includes a chess
pattern language, pattern primitive recognizers, and a pattern
2) Development of a general search tree facility that includes support
for algorithms like best-first search, beam search, breadth-first, and
even alpha/beta minimax.
3) Development of a general planning facility that includes a planning
language, plan generation, and plan execution.
4) Implementation of various machine learning techniques. Many
opportunities exist for this one.