TachiSnap
TachiSnap — Pixel Snapper for animation pixel artists. Rust + WebAssembly client-side tool for cleaning up AI-generated…
WebAssembly port of the strong chess engine Stockfish
WebAssembly port of the strong chess engine Stockfish. See it in action on https://lichess.org/analysis.
Important
See https://github.com/lichess-org/stockfish-web current ports.
This repository is branched from SF_classical
and only kept for compatibility with old browsers.
Uses the latest WebAssembly threading proposal. Requires these HTTP headers on the top level response:
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
And the following header on the included files:
Cross-Origin-Embedder-Policy: require-corp
If headers are not configured correctly on the top level response,
wasmThreadsSupported() as defined below will return false. If headers are
not configured correctly on the included files, something like
pthread sent an error! undefined:undefined: undefined may be logged to the
console.
chrome://flags/#enable-webassembly-threads or
Origin Trial.javascript.options.shared_memory and dom.postMessage.sharedArrayBuffer.withCOOP_COEP to be enabled in about:flags.javascript.options.shared_memory to be enabled in about:flagsNo support.
See stockfish.js for a more portable but single-threaded version.
function wasmThreadsSupported() {
// WebAssembly 1.0
const source = Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00);
if (
typeof WebAssembly !== "object" ||
typeof WebAssembly.validate !== "function"
)
return false;
if (!WebAssembly.validate(source)) return false;
// SharedArrayBuffer
if (typeof SharedArrayBuffer !== "function") return false;
// Atomics
if (typeof Atomics !== "object") return false;
// Shared memory
const mem = new WebAssembly.Memory({ shared: true, initial: 8, maximum: 16 });
if (!(mem.buffer instanceof SharedArrayBuffer)) return false;
// Structured cloning
try {
// You have to make sure nobody cares about these messages!
window.postMessage(mem, "*");
} catch (e) {
return false;
}
// Growable shared memory (optional)
try {
mem.grow(8);
} catch (e) {
return false;
}
return true;
}
navigator.deviceMemory
before allocating.navigator.hardwareConcurrency.
May be capped lower (e.g., dom.workers.maxPerDomain in Firefox).Assuming em++ (^2.0.13) is available:
npm run-script prepare
Requires stockfish.js, stockfish.wasm and stockfish.worker.js
(total size ~400K, ~150K gzipped) to be served from the same directory.
<script src="stockfish.js"></script>
<script>
Stockfish().then((sf) => {
sf.addMessageListener((line) => {
console.log(line);
});
sf.postMessage("uci");
});
</script>
Or from recent node (v14.4.0 tested) with flags
--experimental-wasm-threads --experimental-wasm-bulk-memory:
const Stockfish = require("stockfish.wasm"); // the module, not the file
Stockfish().then((sf) => {
// ...
});
Thanks to the Stockfish team for sharing the engine under the GPL3.
more like this
TachiSnap — Pixel Snapper for animation pixel artists. Rust + WebAssembly client-side tool for cleaning up AI-generated…
.Net 10 (.Net 8+) webassembly starter project using raylib-cs nuget 7.0.2 and raylib 5.5
search projects, people, and tags