Wasm artifacts¶
assets/wasm/ contains the Rust/Wasm build output that the browser loads. These files are not handwritten application logic. They are generated from rust-ai/.
Documentation page:
https://billzi2016.github.io/Othello-AI/docs/en/wasm/
File roles¶
othello_ai.js ES module binding generated by wasm-bindgen
othello_ai_bg.wasm Wasm binary compiled from Rust
othello_ai.d.ts TypeScript declaration file
othello_ai_bg.wasm.d.ts Wasm module declaration file
ai-worker.js imports othello_ai.js. The binding file initializes othello_ai_bg.wasm and exposes the Rust export search_best_move().
How to generate¶
From the repository root:
cd rust-ai
rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli
cargo build --target wasm32-unknown-unknown --release
mkdir -p ../assets/wasm
wasm-bindgen --target web --out-dir ../assets/wasm --out-name othello_ai target/wasm32-unknown-unknown/release/othello_ai.wasm
The input is rust-ai/src/lib.rs and the Cargo dependency graph. The output is the browser-loadable files in assets/wasm/.
Expected result¶
At minimum, a valid build has:
assets/wasm/othello_ai.js
assets/wasm/othello_ai_bg.wasm
If othello_ai.js is missing, the Worker cannot import the module. If othello_ai_bg.wasm is missing, the binding file fails during initialization. The browser console usually shows a 404 or Wasm initialization error.
These files must match the Rust source. After changing rust-ai/src/lib.rs, rebuild the Wasm output. Otherwise the browser still runs the old engine.