p4wn, a smallish javascript chess engine

P4wn is a small public domain chess engine. It was first released in 2002, and substantially revised in 2012.

Instructions

Click on the piece you want to move, then click where you want it to be.

If the game is too easy or hard, click on the computer level button until it seems about right.

When you make a stupid move, you can undo it by clicking on the undo button.

Further instructions can be found in the README file.

News

2012-08-12: P4wn 2.01 released

Version 2 had user interface problems in Microsoft Explorer. Thanks to Uwe Alex for the bug report.

2012-07-03: P4wn 2 released

Version 2 has been released, following the apparent cessation of activity. Read the announcement if you wish, and look out for version 3 in 2022.

Zip and tar files can be found at Sourceforge.

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.

2004-03-25: Sourceforge site registered

This is what you are looking at.

2002-06-16: First released in 5k web competition

Development started in 2000 and skipped 2001.

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.

CC0 To the extent possible under law, the authors have waived all copyright and related or neighboring rights to p4wn. SF logo
Last modified July 2012.