Mindustry logic: how its processors compare with a real CPU
Mindustry is an open-source automation and tower defense game by Anuken (GPL-3.0, on GitHub). Since version 6 it has Mindustry Logic, or mlog, a scripting language that its wiki describes as inspired by assembly: one instruction at a time. You place a processor, link it to buildings, and write instructions such as set, op, jump, read, write, sensor, control, print and wait. The game's source gives the micro processor 2 instructions per tick, the logic processor 8 and the hyper processor 25; a memory cell holds 64 values and a memory bank 512; and logic displays are 80 or 176 pixels square. The op instruction covers arithmetic, comparisons, logical and, and bitwise and, or, xor, flip and shifts. In other words, a Mindustry processor is a small CPU, and every part of it has a real circuit behind it.
How Mindustry's logic maps to a real computer
A processor runs a fixed number of instructions per tick, the way a real CPU runs instructions per clock cycle. Variables are its registers, memory cells and banks are RAM that processors read and write, jump is a conditional branch that loads the program counter, and switches and displays are its input and output. The bitwise operations act on the bits of a number, just like an ALU's AND, OR and XOR. (digiwleea is an independent project, not affiliated with Mindustry or Anuken.)
Building the processor yourself
In Mindustry the processor is a block you place; in digiwleea you build it. In the browser you wire CMOS transistors into gates, gates into adders and an ALU, flip-flops into registers and RAM, add a program counter and control logic, and end with an 8-bit CPU that runs a stored program (LOAD, ADD, STORE, HALT, with the parts for SUB, JMP, JZ and OUT built in Act IV), through a 40+ level course where every part is checked against its truth table, with an AI tutor (Wleea).
| Mindustry | digiwleea | |
|---|---|---|
| Processor | A block: micro, logic or hyper (2, 8 or 25 instructions per tick) | An 8-bit CPU you wire yourself from gates |
| Program | mlog instructions: set, op, jump, read, write, sensor and more | A stored program: LOAD, ADD, STORE, HALT; Act IV adds parts for SUB, JMP, JZ, OUT |
| Memory | Memory cells (64 values) and banks (512) | Registers and RAM built from flip-flops |
| Values | Each variable holds a number (a 64-bit float) or an object such as a block | Bits on wires, 8 to a byte |
| Goal | Automate a factory and defend it | Understand how a computer works, transistor up |
Mindustry parts and the real circuits behind them
- op add, sub. A ripple-carry adder and an adder-subtractor; a whole 8-bit ALU picks among operations.
- op b-and, or, xor, flip, shifts. One gate per bit; try them in the bitwise calculator, and shifts in hardware are a barrel shifter.
- op lessThan, equal. A magnitude comparator.
- jump. A program counter that loads a new address when the condition holds.
- Variables, memory cells and banks. An 8-bit register, a register file and RAM, as in the memory simulator.
- The whole processor. The CPU simulator runs a small assembly program step by step.
No sign-up is needed to start: open the lab and place your first transistor, or read the free theory course. The account (and the AI tutor) are optional.
More comparisons: Games about logic and computers
See for yourself: build a logic gate from transistors in the simulator, then follow the path from sand to an 8-bit CPU.
Open the digiwleea lab →Frequently asked
What is Mindustry logic?
Mindustry Logic (mlog) is the game's assembly-like scripting language, added in version 6. You write it into processor blocks to read sensors, control buildings and units, do math, use memory cells and draw on displays.
How fast are Mindustry processors?
According to the game's source code, a micro processor runs 2 instructions per tick, a logic processor 8 and a hyper processor 25.
Is a Mindustry processor like a real CPU?
Closely. It fetches and runs one instruction at a time, keeps values in variables like registers, branches with jump, and reads and writes memory cells like RAM. A real CPU does the same with circuits: an ALU, registers, a program counter and control logic.
How do I learn how a real processor works?
Build one. digiwleea's free browser course starts with transistors and gates and works up to an 8-bit CPU that runs a stored program, plus the assembly language behind it, with every part checked as you go.