Dev.to
7/26/2026

I shipped a neural-network opponent into the browser: no backend, no accounts, 120 ms per move
Short summary
A developer describes shipping a browser-based four-in-a-row game with a self-trained neural network opponent that runs entirely client-side via ONNX Runtime Web, achieving ~120ms per move. Key decisions include using the WASM-only build, staying single-threaded to avoid COOP/COEP header complexity on shared hosting, and running all inference and tree search inside a Web Worker. The game uses a single ~1M parameter policy+value model with varying search depths to create four difficulty levels.
- •Neural network game opponent runs fully client-side using ONNX Runtime Web with WASM, no backend needed
- •Single-threaded inference avoids SharedArrayBuffer/COOP/COEP complexity; ~120ms per move on desktop
- •Four difficulty levels share one network with different search depths, from heuristic-only to 256-simulation MCTS
Generated with AI, which can make mistakes.
Is this a good recommendation for you?


