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 host6 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.

The climb, floor by floor

The early floors are electromechanical on purpose. Those two starting relays are a default-off switch and a default-on switch, coils moving contacts, and the game makes you feel why NAND is the chosen atom: it is the one gate from which every other gate can be wired, the property logicians call functional completeness. I stared at the half adder longer than I will admit before the penny dropped that addition is just XOR for the sum and AND for the carry.

Each level is a contract. Inputs on the left, required behavior in a table, and the simulator runs your wiring against every row before it pays out. Pass, and the circuit folds into a single named block that joins the component tray, and the tray is the only parts shop there is. Somewhere around the arithmetic floors the game also teaches two's complement by stealth: subtraction arrives as invert-and-add, and negative numbers stop being a notation and become a wiring decision.

The hinge of the whole game is the latch. Everything before it is combinational, outputs trailing inputs instantly, and then one feedback loop later the circuit remembers something. From that single remembered bit the next floors assemble registers, a program counter and RAM, and the moment a clock starts stepping your memory forward is the moment the board stops being a puzzle and starts being a machine. The RAM is built the honest way, registers multiplexed behind an address decoder, and watching a word of memory answer to its address is the best explanation of a bus I have ever been given.

The top floors are where the vertigo lives. You wire an arithmetic unit whose operation is picked by control bits, a condition unit that decides jumps, then a control unit that decodes each 16-bit instruction into all of those wires at once, and the loop closes: fetch, execute, step the counter, forever. Then the game flips direction on you: instead of wiring hardware up, you write machine code down, small programs that the CPU you assembled runs step by step. Nothing was handed to you on the way up. Every block in the final diagram is one you built.

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.

That sounds like a detour until you watch the board in motion. Wires snap to pins, junction dots appear where they belong, blocks drag with their connections live, and the diagram stays legible even at CPU scale, when the thing on screen is dozens of your own components deep. Off-the-shelf graph libraries draw boxes and arrows; this is a circuit you debug. Writing it by hand is why the game feels like a tool instead of a toy.

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.

There is no account and no backend worth the name, either. I watched the network tab after load and the game goes quiet; your progress and your half-finished adder live in your browser. Once a circuit passes its spec nothing stops you from rebuilding it leaner, and the thread is full of people doing exactly that for sport.

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.

Siblings on the workbench

The NAND-up genre has grown since 2018, and the two best companions take the same climb through opposite doors.

Turing Complete is the polished commercial cousin: 70-plus levels from NAND gates to full CPU architectures, with screens, timers, sound, keyboard input and even networking waiting at the top, and you finish by designing your own assembly language for a machine of your own design. It landed on Steam in October 2021, sits at 94 percent positive across 3,020 reviews, and the store page budgets 50-plus hours for the trip.

Ben Eater's 8-bit breadboard computer takes the other exit: off the screen entirely. He built a programmable 8-bit machine from scratch on breadboards using simple logic gate chips, documented module by module on video, clock, registers, ALU, RAM, program counter, control logic, and sells the parts as kits so you can wire yours with actual wire. His site even walks the floors below the Nand Game's ground level, with videos on semiconductors, transistors and latches, the physics underneath the relay. The kits mean the only part you cannot order is the patience.

So the honest comparison shakes out like this: the Nand Game is the free afternoon, Turing Complete is the fifty-hour semester, and Eater's series is the one that ends with blinking LEDs on your desk.

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 course is the teaching half of The Elements of Computing Systems, the MIT Press book by the same two authors, and the projects, lectures and tools are all free on the site, with paid Coursera versions when you want the certificate on paper. The enrollment spread the site describes runs from high schoolers to doctoral candidates and working engineers, which sounds right: the question it answers does not expire with seniority. 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