Handwired

Normal code, turned into a neural network. Then networks that run other networks. All in CSS, with 0 bytes of JavaScript.

step 1

Tic-tac-toe, one network

The computer player and all its rules in a single network. It plays exactly like before.

Play →
step 1

Connect four, one network per turn

One network drops the pieces, thinks, blocks and plays: a whole turn.

Play →
step 2

Swap the brain

A fixed “console” network plays whichever strategy you load into it, like swapping cartridges.

Swap →
step 3

Nesting dolls

A console running a console running a tiny network. Both give the same answers.

Look →
step 4

A rule that keeps learning

A rule written by hand becomes a network, then keeps learning from the points you place.

Teach it →
step 5

A computer made of neurons

A tiny 8-bit computer whose every clock tick is one network. It runs real programs (counting, Fibonacci, multiplying) or one you write yourself.

Run it →
step 6

A game console made of neurons

Snake on a tiny 8-bit computer whose every clock tick is one network. The screen is its memory; the game is a 42-instruction program.

Play →
step 7

A tiny desktop run by one network

Three windows and a dock. Every click goes through one network that decides what happens to every window.

Click around →
How it works (for the curious)

The compiler

handwired/scripts/hw.py is about 450 lines. A program is built from inputs, constants, +, constant × and relu; helpers give integer logic (ge, eq, AND, OR, gating, a lexicographic argmax). compile() places each ReLU at 1 + the depth of its deepest input, carries values that are needed further down through identity units, and returns an ordinary layered integer MLP. The same net runs in numpy, and to_css() writes it out as registered @property integers.

CodeBecomes
x ≥ t (integer x)relu(x − t + 1) − relu(x − t)
x == trelu(x − t + 1) − 2·relu(x − t) + relu(x − t − 1)
a && b && crelu(a + b + c − 2)
a || b || …s − relu(s − 1)
bit ? v : 0, 0 ≤ v ≤ Mrelu(v − M·(1 − bit))
⌊u / 2^j⌋round(relu(2u + 1 − 2^j) / 2^(j+1)), one integer unit
w * x, both inputsthe bits of w, each gating x, summed with powers of two
Rebuild with .venv/bin/python handwired/scripts/build.py --nets, test with node handwired/tests/browser.test.mjs. See handwired/README.md.