I Asked an AI Running Inside a Browser Tab to Write a Commodore 64 Game

Linux in a tab, an AI model in that Linux, a C64 as the judge. What could go wrong?

The unkernel page in Chrome: an ollama terminal with Qwen3 answering "Hey, how's it going?" at 10.82 tokens per second, next to a Debian shell showing its disks

This started as a quick look at a new open-source project and turned into a stack of layers that would have sounded like a joke a few years ago:

  1. Chrome, running on a Windows laptop
  2. Linux 7.3, compiled to WebAssembly and running in a tab
  3. Debian 13, booted inside that kernel
  4. ollama, installed inside Debian
  5. Qwen3, a small open language model, running on the laptop's GPU through the browser's WebGPU
  6. …asked to write a game for a Commodore 64, a computer from 1982

Here's how each layer works, what broke, and whether we got a playable Snake game out of it.

Layer 1: Linux in a tab

The project is unkernel. It isn't an emulated PC like QEMU-in-the-browser projects. It's the actual Linux kernel compiled to WebAssembly: scheduler, memory management, ext4 and TCP/IP. Programs inside it are ordinary ARM64 Alpine or Debian binaries, run by a CPU emulator with a JIT that compiles hot code to WebAssembly on the fly.

The devices are bridged to browser APIs:

  • Disks live in the browser's private storage (OPFS) and survive reloads.
  • The network is tunnelled over a WebSocket to a relay.
  • The GPU goes through WebGPU.

Numbers:

  • The hosted page booted Debian in about 7 seconds with 4 CPUs.
  • My own local copy booted in about 9 seconds with 1 CPU.
  • The command-line version, npx unkernel, booted Alpine in about half a second.

Getting it running on a locked-down Windows laptop

  • Node 24: the command-line version needs it. One winget install OpenJS.NodeJS.24 handled that.
  • PowerShell's script policy: npx unkernel failed with "running scripts is disabled on this system". That's PowerShell's execution policy blocking npx.ps1. npx.cmd unkernel runs the same tool as a batch file and works fine. (More on why that matters in the companion security post.)
  • The browser page locally: cloning the repo and running pnpm install was enough. The production build was the easiest to serve. The page pulls the prebuilt kernel from the project's release mirror, so you don't need a Linux toolchain.
  • One quirk: on my machine the local page only booted with ?cpus=1. The extra CPU workers wouldn't start.

Layer 2: an AI model inside it

The Debian image includes a ready-made ollama launcher. Ollama talks to the guest's Vulkan driver, which unkernel translates to the browser's WebGPU, which Chrome runs on Direct3D 12. A menu offers small models from 100 MB to about 1.3 GB. I picked Qwen3 1.7B (1,296 MiB).

It worked. "Hey, how's it going?" got a friendly answer after a visible thinking pass, at 10.8 tokens per second.

Then I noticed the System panel saying WebGPU intel gen-12lp. The whole time, it had been running on the laptop's integrated Intel Iris Xe graphics, not the NVIDIA RTX A2000 sitting next to it.

Windows Task Manager showing the Intel Iris Xe at 69% and the RTX A2000 idle at 0% while the model works on the Snake prompt

Switching to the NVIDIA GPU

Chrome uses whichever GPU its GPU process starts on. The fix is entirely on the Windows side:

  1. Open Settings > System > Display > Graphics and set Chrome to High performance.
  2. Exit Chrome completely.
  3. Reopen the page.

After that the System panel read WebGPU nvidia ampere, and ollama reported 29 of 29 layers on the GPU, loaded in 23.5 s.

ollama's model menu, then "offloaded 29/29 layers to GPU (100% GPU), loaded in 23.5 s", with the System panel's Vulkan card reading "WebGPU nvidia ampere"

Layer 3: the challenge

The prompt, in short:

  • A complete, playable Snake game for a stock Commodore 64, in BASIC V2 only, with no machine code.
  • WASD controls, a border, a growing snake, food that never spawns on the snake, collisions, a score, rising difficulty, and a restart that doesn't need RUN.
  • No ELSE, MOD, WHILE or DO, because BASIC V2 doesn't have them.
  • And remember that only the first two letters of a variable name count.

This is a great test for small models. BASIC V2 is old, unforgiving and full of traps. My favourite: the C64 tokenizer finds keywords inside variable names, so SCORE is read as SC + OR + E and the line fails with a syntax error.

Attempt 1: the infinite PRINT

After a long thinking pass, the model started the program and then wrote PRINT " " lines. Thousands of them. By line 3130 it was clearly stuck. This is a repetition loop, a classic failure in small models: each identical line makes the next one more likely, and a model can't go back and edit what it already wrote.

The ollama terminal filling with numbered PRINT lines containing only spaces, lines 240 to 560 and counting

Attempt 2: a literal snake

With sampling adjusted (temperature 0.6, top_p 0.95, top_k 20, repeat_penalty 1.1), the model produced… ASCII art of a snake, drawn with PRINT statements. It had read "Snake game" as "draw a snake". Then it got stuck repeating one line again.

The model's "BASIC Program": PRINT statements drawing a snake's head in ASCII art, then the same |_______| body segment repeated from line 100 onwards

Attempt 3: a prompt with a design

For the third try I cleared the session and gave the model a design to follow:

  • POKE the screen memory directly.
  • Keep the snake in a ring buffer.
  • PEEK the screen to detect collisions.
  • Plus an explicit warning about keywords hiding inside variable names.

This time it finished: a tidy 44-line program and a confident explanation ending with "All code adheres to BASIC V2 rules: no ELSE, MOD, WHILE…"

The program uses WHILE TRUE, ELSE IF and END IF. It names a variable new_x, which contains NEW, the BASIC command that erases the program. Its very first loop does POKE 1024 + i*256, 160, as if screen rows were 256 bytes wide; on a C64 they're 40.

In an online C64 emulator you can watch exactly that happen:

  • Four black squares appear, one for each of the first four loop passes. Each is 256 bytes, or six and a bit rows, further along than the last, which is why they march diagonally across the screen.
  • On the fifth pass the loop starts writing over the BASIC program itself, and the machine scrambles itself into stripes.

An online C64 emulator running the program: four black squares stepping across and down a purple screen striped with dark bars, next to the listing with WHILE TRUE, ELSE IF, END IF and new_x

That's the most useful lesson of the experiment: the output looked finished, and the model said it was correct. A small model's self-check is not a check.

Speed: 5,176 tokens in 25 minutes 36 seconds, 3.4 tokens per second on the Iris Xe with an 8,192-token context window.

Attempt 4: the same run on the NVIDIA GPU

Same model, same settings, same prompt, on the RTX A2000:

Intel Iris Xe RTX A2000 Speed-up
Generation (eval rate) 3.4 tokens/s 10.1 tokens/s ~3x
Reading the prompt (prompt eval rate) 32 tokens/s 471 tokens/s ~15x
Wall-clock time 25 min 36 s for 5,176 tokens 10 min 23 s for 6,244 tokens

The GPU tripled generation speed even with every call passing through WebGPU inside a browser tab.

The code got worse. Halfway through its thinking, the model got stuck on how to detect the snake hitting its own body. It repeated the same two lines, 360 IF PEEK(1024+H)=160 THEN GOTO 360, dozens of times. Each time it wrote "But this is not helpful", then concluded "the code would be correct as written." Its final answer was three lines:

100 GOSUB 100
100 IF PEEK(1024 + H) = 160 THEN GOTO 100
110 IF PEEK(1024 + H) = 160 THEN GOTO 100

The model's reasoning on the A2000: lines 370, 380 and 390 are the same collision check repeated, followed by "but how to implement delay in BASIC V2?"

It has two line 100s, and a subroutine that calls itself until the C64 runs out of stack. It came with the description "clean, efficient, and handles basic collision detection correctly."

The GPU didn't cause this. At temperature 0.6 every run samples differently, so the same model and prompt can produce very different results. A faster GPU gets you to the result sooner; it doesn't make it better.

Attempt 5: a bigger model

If 1.7 billion parameters weren't enough, maybe 4 billion would be. I asked for 8 GiB of guest memory (?mem=8192) and pulled Qwen3 4B.

I only spotted later, in my screenshots, that the browser said no. The boot log reads "Allocated 1024 MiB of memory (8192 MiB failed)": Chrome couldn't reserve 8 GiB for the tab, so unkernel quietly fell back to 1 GiB. The model ran anyway, because its weights live in GPU buffers outside the guest's own memory.

unkernel's boot log with a yellow WARN line: "Allocated 1024 MiB of memory (8192 MiB failed)"

On the GPU side it fit, just about:

  • All 37 layers loaded onto the A2000.
  • 3.3–3.5 of the GPU's 4.0 GB of dedicated memory in use, plus 0.6–1.1 GB spilling into shared system memory.
  • The GPU sat at 58–61 °C, and the laptop got noticeably warmer.

It was also much slower. Even its replies to the parameter commands took a while.

Task Manager during the 4B run: the RTX A2000 at 40% and 62 °C, its utilization graph spiking up and down

The reasoning was better than the 1.7B model's, up to a point:

  • It knew the two-letter variable rule. It noticed that DIR and D would clash and settled on a single D.
  • It worked out a reverse-direction check that's actually valid BASIC V2: IF K$="W" THEN IF D<>2 THEN D=0.

Then it drifted:

  • It planned a first line of CLEAR, a command BASIC V2 doesn't have (the C64's is CLR).
  • It reached for ' comments, which BASIC V2 doesn't support.
  • It worked out screen addresses as 1024 + (y*320 + x)*2, confusing the 40-column text screen with the 320-pixel bitmap mode.
  • It shrank the playfield, from the full screen to 4x4, then 5x5, then 10x10, trying to make the problem small enough to finish.

Then it wrote, quite honestly:

This is getting too complex.

Alternative plan

I stopped it there, more than two hours in, without a single line of finished code. With no end in sight and other work waiting, this was the point to call it.

The model's reasoning ends with "This is getting too complex." and "Alternative plan", followed by ^C and /clear

Where does the time go?

unkernel's System panel counts every GPU job the guest sends, so I could compare the two runs on the A2000:

Qwen3 1.7B Qwen3 4B
GPU jobs (compute dispatches) per second 5,821 455
Batches sent to the GPU (submits) per second 183 12
Guest CPU (one emulated core) 77% busy ~3%
A2000 utilization ~32%, steady 31–57%, spiky

The System panel's Vulkan card during the 1.7B run: 5,821 compute dispatches per second, next to Task Manager showing the A2000 at 32%

At about 10 tokens per second, the 1.7B model was sending roughly 580 GPU jobs per token. Every one of them makes a full round trip:

  1. ollama hands the job to the guest's Vulkan driver.
  2. The guest kernel passes it out to the tab's JavaScript.
  3. The tab sends it to Chrome's GPU process.
  4. Chrome sends it on to Direct3D 12 and the GPU.
  5. The result comes all the way back the same way.

With the small model, the emulated CPU was the bottleneck. Ollama runs on a single emulated ARM core, and that core was 77% busy preparing all those jobs, while the A2000 sat at about a third of its capacity. That's also why prompt reading sped up ~15x on the A2000 but generation only ~3x: the prompt goes in big batches that keep the GPU busy, while generation is one token at a time, with the emulated CPU in between each step.

With the 4B model, nothing was busy. During the 4B run I checked every layer:

Layer What it was doing
Debian guest (top inside the tab) ~3% CPU
The unkernel tab in Chrome's Task Manager, including its workers 10.7% of one core
Chrome's GPU process 4.7% of one core
RTX A2000 Spiking between near-idle and busy
Windows overall ~40% CPU, mostly other software

The job rate fell more than tenfold, and every layer spent most of its time waiting on the next. Bigger models mean bigger jobs. The GPU memory was full and spilling into slower shared system memory, and the guest was squeezed into 1 GiB. I can't say which of those dominated. But the result was the same: a model that's only about twice the size ran far more than twice as slowly.

Scoreboard

Run GPU Model Tokens/s Result
Hello chat Intel Iris Xe Qwen3 1.7B 10.8 Friendly answer
Snake #1 Intel Iris Xe Qwen3 1.7B n/a (stopped) Infinite PRINT loop
Snake #2 Intel Iris Xe Qwen3 1.7B n/a (stopped) ASCII-art snake, then a loop
Snake #3 Intel Iris Xe Qwen3 1.7B 3.4 Finished; scrambles the C64
Snake #4 RTX A2000 Qwen3 1.7B 10.1 Thinking loop; 3-line program that recurses forever
Snake #5 RTX A2000 Qwen3 4B n/a (stopped) Better reasoning; "This is getting too complex."

Final score: C64 5, AI 0. No playable Snake, but a lot learned along the way.

What I took away

  • The browser is a real computer now. A full Linux distribution, package manager, AI runtime and GPU compute, from a URL, with nothing installed. That's remarkable engineering.
  • GPU choice matters, and Windows decides it. If you test in-browser AI on a laptop, check which adapter WebGPU actually got.
  • Small models are fun, not reliable. At 1–2 billion parameters, expect repetition loops, misread instructions and confident wrong answers. Prompt structure helps more than sampling tweaks.
  • Bigger models reason better but pay for every layer. The 4B model understood more of the rules, but each extra calculation made the same slow round trip through five layers. For anything beyond tiny models, a tab-hosted AI is a demo, not a tool.
  • Old platforms make great benchmarks. BASIC V2 has nowhere to hide: it either runs on a 1982 machine or it doesn't.
  • Every layer in this stack is invisible to traditional IT controls. It's one browser process with one WebSocket. That's the subject of the companion post on browser-tab security.