If all you're interested in doing is playing chess, then click here.

What is it?

Simply put, a Java applet that plays chess! I learned Java by reading Just Java 2 by Peter van der Linden (and an excellent book it is too). Peter included on his CD a program for playing chess by David Dagon [He has a homepage here but I don't think it's a current one]. The program was incomplete, and Peter mentioned he'd put a more complete version on the CD if one was written, so I ended up spending some time rewriting and finishing it. Once I had a nice-ish interface that could play chess, I began thinking about writing an engine [what does that do?], decided I'd rather steal someone-else's and ended up translating Tom Kerrigan's excellent tscp into Java.

It has been rewritten a little since then, most notably to do Negascout rather than Negamax search. It also uses bitmaps to generate its pawn moves.

The Code

The source code (v0.8.1) is available. (If you are simply wanting to know how chess programs work then v0.2.2 is a little simpler to understand.) A brief outline of how the chess engine works is available. I would welcome helpful comments and patches. Please send them to I would prefer patches made with diff -u but if you don't know what that means or don't have access to diff on your platform, send the patches in whatever format you like.

I am currently interested in adding:

But I would prefer the applet to remain less than 100K. Since the jar file is currently about 30K this doesn't seem a stringent requirement. Also, though I want to produce an applet that plays good chess, clear, maintainable code is also a consideration, so unless they change things quite obviously for the better, clever optimisations that destroy the readibility of the code are not what I am looking for.

The code is licensed under a BSD-style license. I have permission from both David and Tom to do this.


I have no idea how strong the applet is. Sadly, I'm not really a strong enough player myself to have much chess knowledge. The applet uses the evaluation algorithms of tscp, so it is comparable to tscp, I suppose, except for the fact that it has a negascout, rather than a negamax algorithm for the search.

The exciting thing from my point of view is that it plays a reasonable game of chess at a reasonable rate. ChessApp evaluates about 30000 boards per second on my PowerBook. When I compiled tcsp without compiler optimisations on the same machine, it got about the same rate, though with optimisations it manages nearly three times that. Still, I think that's not bad for an interpreted language!

The Applet

WARNING:You need a Java 2 platform to play this game. New versions of Mozilla have a plugin that supports Java 2. Mac OS X (which is what I use) provides a Java 2 environment to its browsers, so most should work. If your browser does not, install a Java 2 JRE. To move, drag the piece to the new square. To castle, move the king and the rook will be moved automatically. (NOTE to previous users - in the new version you need to drag pieces rather than clicking them!)

Your browser doesn't appear to support Java

This page has been written by Peter Hunter. The page, the source code and the applet on this page are copyright © 2002 Peter Hunter.