
Between 2001 and 2004,
John Wielgley wrote
emacs-chess, a rather
complete Chess library for Emacs. I found it around 2004, and was immediately
hooked. Why?
Because Emacs is configurable, and I was hoping that I could customize the
chessboard display much more than with any other console based chess
program I have ever seen. And I was right. One of the four
chessboard display types is exactly what I was looking for,
chess-plain.el:
8 tSlDjLsT
7 XxXxXxXx
6
5
4
3
2 pPpPpPpP
1 RnBqKbNr
abcdefgh
This might look confusing at first, but I have to admit that I grew rather
fond of this way of displaying chess positions as ASCII diagrams.
In this configuration, initial letters for
(mostly) German chess piece names are used for the black pieces, and English
chess piece
names are used for the white pieces.
Uppercase is used to indicate if a piece is on a black square
and braille dot 7 is used to indicate an empty black square.
chess-plain is completely configurable though, so you can have more classic
diagrams like this as well:
8 rnbqkbnr
7 pppppppp
6 + + + +
5 + + + +
4 + + + +
3 + + + +
2 PPPPPPPP
1 RNBQKBNR
abcdefgh
Here, upper case letters indicate white pieces, and lower case letters black
pieces.
Black squares are indicated with a plus sign.
However, as with many Free Software projects, Emacs Chess was rather dormant
in the last 10 years. For some reason that I can not even remember right now,
my interest in Emacs Chess has been reignited roughly 5 weeks ago.
Universal Chess Interface
It all began when I did a casual
apt-cache serch for chess engines,
only to discover that a number of free chess engines
had been developed and packaged for Debian in the last 10 years. In 2004 there was basically
only
GNUChess,
Phalanx and
Crafty. These days, a number of
UCI
based chess engines have been added, like
Stockfish,
Glaurung,
Fruit or
Toga2. So I started by learning how the new chess engine communication
protocol, UCI, actually works. After a bit of playing around, I had
a basic engine module for Emacs Chess that could play against Stockfish.
After I had developed a thin layer for all things that UCI engines have in common
(
chess-uci.el),
it was actually very easy to implement support for Stockfish, Glaurung
and Fruit in Emacs Chess. Good, three new free engines supported.
Opening books
When I learnt about the UCI protocol, I discovered that most
UCI engines these days do not do their own book handling.
In fact, it is sort of expected from the GUI to do opening book moves.
And here one thing led to another. There is quite good documentation
about the
Polyglot chess opening book binary format on the net.
And since I absolutely love to write binary data decoders in Emacs Lisp
(don't ask, I don't know why) I immediately started
to write Polyglot book handling code in Emacs Lisp, see
chess-polyglot.el.
It turns out that it is relatively simple and actually performs very good.
Even a lookup in an opening book bigger than 100 megabytes happens
more or less instantaneously, so you do not notice the time required
to find moves in an opening book. Binary search is just great.
And binary searching binary data in Emacs Lisp is really fun :-).
So Emacs Chess can now load and use polyglot opening book files.
I integrated this functionality into the common UCI engine module,
so Emacs Chess, when fed with a polyglot opening book, can now choose
moves from that book instead of consulting the engine to calculate a move.
Very neat! Note that you can create your own opening books from
PGN collections, or just download a polyglot book made by someone else.
Internet Chess Servers
Later I reworked the internet chess server backend of Emacs Chess a bit
(sought games are now displayed with tabulated-list-mode), and found
and fixed some (rather unexpected) bugs in the way how legal moves
are calculated (if we take the opponents rook, their ability to castle needs
to be cleared).
Emacs Chess supports two of the most well known internet chess servers.
The Free Internet Chess Server (FICS) and chessclub.com (ICC).
A Chess engine written in Emacs Lisp
And then I rediscovered my own little chess engine implemented in Emacs Lisp.
I wrote it back in 2004, but never really finished it.
After I finally found a small (but important) bug in the static position
evaluation function, I was motivated enough to fix my native Emacs Lisp
chess engine. I implemented quiescence search so that captue combinations
are actually evaluated and not just pruned at a hard limit.
This made the engine quite a bit slower, but it actually results in relatively
good play. Since the thinking time went up, I implemented a small
progress bar so one can actually watch what the engine is doing right now.
chess-ai.el is a very small Lisp impelemtnation of a chess engine.
Static evaluation, alpha beta and quiescence search included.
It covers the basics so to speak.
So if you don't have any of the above mentioned external engines installed,
you can even play a game of Chess against Emacs directly.
Other features
The feature list of Emacs Chess is rather impressive. You can not
just play a game of Chess against an engine, you can also play against another
human (either via ICS or directly from Emacs to Emacs), view and edit
PGN files, solve chess puzzles, and much much more.
Emacs Chess is really a universal chess interface for Emacs.
Emacs-chess 2.0
In 2004, John and I were already planning to get emacs-chess 2.0 out the door.
Well, 10 years have passed, and both of us have forgotten about this wonderful
codebase.
I am trying to change this. I am in development/maintainance mode
for emacs-chess again. John has also promised to find a bit of time
to work on a final 2.0 release.
If you are an Emacs user who knows and likes to play Chess, please
give emacs-chess a whirl. If you find any problems, please file
an Issue on Github, or better yet, send us a Pull Requests.
There is an emacs-chess Debian package which has not been updated in a while.
If you want to test the new code, be sure to grab it from GitHub directly.
Once we reach a state that at least feels like stable, I am going
to update the Debian package of course.