The Lock That Knows Its Code
Before level 17 the game offers a short interactive intro: a combination lock built from two lamps and an AND gate opens on exactly one code. This page tells the same story in text.
Experiment: the door opens on one code
Two lamps set a two-digit code: the lamp weighted 2 is the left digit, the lamp weighted 1 is the right one. The Door lamp is the door. Try all four codes: 00, 01, 10, 11. The door opens once — on code 10. The wires and gates never changed: only the lamps did.
Predict: code 11
Both lamps are lit — code 11. Will it open the door? No. Inside the lock an AND gate checks every bit of the code: on code 10 both of its inputs are one; on any other code at least one input is zero. The AND outputs 1 only when every check matches at once. The circuit never notices a partial match: a lamp is either lit or not.
The rule: the circuit recognizes a code with chains of ANDs
Code recognition is built from AND gates: each input bit is compared with its reference digit, and the results converge into a single AND. The circuit "recognizes" the code that was built into it. That node is a decoder — it turns a number-code into one signal saying "this is my code". For a processor, an operation is a number too: the op code says what to do, and the decoder recognizes it the same way the lock knows its code.
Where it is used
On level 17 you will build recognition for three commands: ADD, STA and JMP. The instruction byte comes in, chains of AND gates match its upper four bits — the op code — and the right control-signal line lights up. Without a decoder, a processor could not tell "add" from "store to memory".