WOAH
The Nand Game's first level, a wiring board with relay components, a truth table, and a welcome panel explaining the goal

Machines

Build a working CPU starting from a single NAND gate

By The host2 min#hardware#logic#games

The Nand Game hands you one NAND gate and has you wire your way up through logic, adders and memory to a real processor that runs machine code, in the browser.

The first level gives you two relays and one job: wire them into a NAND gate. A truth table on the left, a blank board. That is the entire starting kit for building a computer.

The Nand Game, by Olav Junker Kjær, is a puzzle that walks you all the way up. From that single NAND you build NOT, then AND and OR and XOR. From those you build an adder, then a whole arithmetic unit. Then latches, which give you memory, then registers and RAM, then an instruction set, until the last levels have you running actual machine code on a processor you assembled yourself.

The clever part is the constraint. Each level gives you only the pieces you have already built, and once your circuit passes its specification, it collapses into a single reusable block for the next level. So the complexity is real but never dumped on you: a CPU is just a NAND gate, wrapped in a NOT gate, wrapped in an adder, wrapped a few hundred more times.

I went looking for an official level count and could not find one, but I can tell you where the climb ends: a working 16-bit machine that addresses 64K words of memory, which is 128KB, a figure Kjær corrected in the level text after a player caught it reading 64.

Built by hand, like the thing it teaches

Kjær showed the game on Hacker News in July 2018, where it drew 143 points and a thread of bug reports he fixed as they arrived. His comments there double as the blueprint. The app is written in Angular and, in his words, "no library beyond that": he shopped for an off-the-shelf diagramming library, found nothing that fit a wiring board, and wrote the whole surface of components, connectors and arrows as custom code.

It still ships lean. I checked: the game arrives as one JavaScript bundle of about 856KB, and from there every simulation runs client-side, your circuit checked against its truth table by your own CPU while you assemble its small cousin.

The same thread names his sources. The game follows the opening chapters of Nand2Tetris, the build-a-computer course by Noam Nisan and Shimon Schocken, and Kjær got their permission to reuse the same general CPU design.

When the afternoon is over

Nand2Tetris itself is the next door: free, taught at more than 400 universities, schools and bootcamps, and it keeps climbing past the hardware into assemblers, compilers and an operating system until Tetris runs on the machine you drew. The game answers a question most working programmers have quietly carried for years, what is actually down there under the code. The course lets you keep digging.

Once you know the layers, the browser tricks stop looking like magic. A full Debian system booting in a tab is the same stack of wrappers, just taller.

More electronics you assemble and watch run: a circuit simulator that re-solves itself every few microseconds.

Next up

The Game of Life went continuous and started growing creatures