Connect Four: a smaller AI in your browser (Size)

Can the AI from the main demo get much smaller? Yes: trained with ternary weights (-1, 0 or +1, times one scale per 128 weights), a new model fits in a 1.6 MB file, a fifth of the 7.8 MB int8 model, and plays at about the same level. Every AI here runs on your GPU with onepass-webgpu, the runtime from the speed demo; the code, results and models are in onepass-webgpu-ternary and on Hugging Face.

The story: Meet your one-pass AI opponent (the model) · One millisecond to make a move (the speed) · A game-playing AI in 1.6 MB (the size).

Downloading the AI…

How the AI sees the board

The AI's preference for each column appears here after it moves.

Size and play

Download size against strength. The game scores are fixed test results; the last three columns are measured here, on the same 200 boards from complete games as the speed demo.

playerdownloadvs depth-4 bot vs depth-6 botperfect movesmedian mean

Download: the model file plus the code that runs it. Game scores: 200 games from the empty board, both sides playing a random move 5 % of the time, a win counts 1 and a draw ½ (so even a perfect player loses some). Perfect moves: how often the player picks a move the solver rates best. The times depend on your machine; on an idle M5 Pro a move takes 1.1 ms (T34), 1.3 ms (Base243) and 0.9 ms (dense int8). The dense v2 game scores were measured with onnxruntime-web's int8 arithmetic; here the same file runs with int8 weights and float math, which stays slightly closer to the original model. Blue marks the best value in each column, red the worst.

Technical checks

On every load the page re-encodes reference positions and compares them with the Python tooling's bytes, then checks every model's scores on the GPU against the expected scores for its file.