The strong open source chess engine Stockfish compiled to JavaScript using Emscripten. See it in action for local computer analysis on lichess.org.
About 1MB uncompressed, 220 KB gzipped:
- stockfish.js based on original Stockfish
- stockfish.js with multi-variant support by @ddugovic
Install Emscripten, then:
cd src
make ARCH=js build
var stockfish = new Worker('stockfish.js');
stockfish.addEventListener('message', function (e) {
console.log(e.data);
});
stockfish.postMessage('uci');- Expose as web worker.
- Web workers are inherently single threaded. Limit to one thread.
- Break down main iterative deepening loop to allow interrupting search.
- Limit total memory to 32 MB.
- Disable Syzygy tablebases.
- Disable benchmark.
Thanks to @nmrugg for doing the same thing with Stockfish 6, to @ddugovic for his multi-variant Stockfish fork and to the Stockfish team for ... Stockfish.