P4wn, a javascript chess engine
This is a small javascript chess engine. It was originally written by Douglas Bagnall between 2000 and 2002, and a version of it was entered in the 2002 5k competition. Various people have added bits and pieces over the years, and in 2012 it was substantially rewritten to ease modification and embedding.
P4wn has been placed in the public domain with a CC-zero dedication. That means you can do whatever you want with it without asking anyone.
News
2012-03-22: P4wn 2 also on Github
At https://github.com/douglasbagnall/p4wn. The clarified code is currently known as “almost version 2”.
2012-03-19: Switch to Git, with clarified code
All of a sudden I decided to pay some attention to this. The git repository obsoletes the CVS, and the code has had some attention to make it explicable.
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.
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.
Mailing list
There is a mailing list hosted by sourceforge, which averages about two messages per year. Ask any questions there.
Similar Projects
Gary Linscott wrote Garbochess-JS. It seems much stronger than p4wn, and uses the WebWorkers javascript to keep the UI going while it schemes away in the background.
Óscar Toledo G. has written various tiny chess engines in various languages, including javascript. Óscar Toledo is the undisputed world champion of chess minification and obfuscation. His code manages to somehow be humorous at the same time as being unreadably compact. It plays quite well, too.
Neil Pearce wrote a javascript chess game which no longer seems to be online.
There was one by David Moore in the 2001 5k competition. Now it is here.
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.