Around January 2007 I remembered the similarities between C
and Javascript, and I was wondering if it would be possible to do a
translation of my recent winning entry (19th IOCCC,
Most Portable Chess Set), I did it on an afternoon and the result is the
current world's smallest chess program in Javascript.
You can select the
promotion piece using the control. Some browsers will show you a
message of script being too slow, please indicate that you DON'T want to
stop the script.
See it on action, to play click piece to move and then click
destination square:
If you want to play with black's pieces, click this
to force a move, you will need to click every time after you do a move.
The source code
Most of the code is a resemblance of the original code,
except for the pointers translated to array-access. Recently I updated the core
with code from Toledo Nanochess Nov/20/2009.
Play level is fixed at 3-ply depth, you can modify it
(search on the source code for /*ply*/), be careful as every extra ply
is an order of magnitude more slow.
A brief description of the inner workings of this code can
be found on the page of Toledo Chess 1.
Douglas Bagnall wrote the first 5K Javascript Chess Game,
current smallest programs based on his source exceeds 4 kilobytes. These
programs and others are available at
http://p4wn.sourceforge.net/