Javascript Chess

In 2002 I (Douglas Bagnall) wrote a javascript chess game for the 5k competition. People are still curious about it, so it has finally gained its own sourceforge site.

The code is now in the public domain. That means you can do whatever you want with it; there is no copyright.

News

2005-03-23: Sven Vahar's fancy version in CVS

The improved board that Sven Vahar made in December 2004 is now available in CVS, and as a zip download.

2005-03-04: Unicode version by Antony Lesuisse

Antony Lesuisse replaced the external gifs with unicode glyphs, creating a completely self-contained page of only 4385 bytes. It has been added to CVS.

If you don't see a row of chess pieces here (♔♕♖♗♝♞♟), you might have problems using the page - it depends on your browser's font rendering.

2004-12-14: New version by Sven Vahar

Sven Vahar has created a cleaner interface with help text, with both Estonian and English versions.

Different Versions

The code has forked a few times already, due mainly to a lack of version control. I think this is an OK thing with such a tiny program, allowing experiments and varying objectives. If you want to take it in a new direction, please do. New forks are welcome in the CVS tree. The main branches are:

How it works

It recursively explores the tree of possible moves, keeping score along the way. It tries to take as many pieces as possible and get into the centre early. That's about all. Its endgame strategy is to win before the endgame.

Bugs

It doesn't always lose graciously, often trying to move out of checkmate. You could take that as a concession, but it is irksome.

To do

(incomplete list)

Similar Projects

Neil Pearce has written a javascript chess game which can be found at internet.com and other places.

There was one by David Moore in the 2001 5k competition. Unfortunately it won't work in my browsers.

The most famous small chess implentation is probably the 1k ZX81 game. Not only is it short, it ran in only 1024 bytes of ram (javascript has megabytes to play with). On the other hand, it didn't know all the rules.

License (or lack thereof)

Most popular free licenses are longer than the code, and often refer to things that don't apply well to a webpage (such as the source/binary distinction). So it is public domain.

SF logo
Last modified March 2005.