Foundations
Truth Tables
A way to write down every case a question can have, so you can see that two different-looking tests are the same test.
Begin — Unit 01 →What this is
You can already join questions together. alive AND ammo > 0 is a test you know how to
write, and General Programming taught you to write it.
This is the other half. Not how to write a test, but how to know what it does: all of it, every case, with nothing left to wonder about.
The instrument is a truth table. It is a small grid that lists every combination the inputs can be in and what comes out of each one. Because it lists every combination, it does not leave you a corner to be wrong in.
Who it’s for
Anyone whose IF has grown a second condition, then a third, and has stopped being sure
what it does.
That happens quickly. A guard like “let them jump if the button is down and they are on the ground and they are not stunned” is three conditions with two words joining them, and the difference between what you wrote and what you meant is not visible by staring.
You need no binary and no machine for this. It is reasoning, and it works the same whatever you write it in.
What it is not
This does not teach AND, OR and NOT. You have those.
Nor does it teach circuits. That comes later, in Gates and the Adder, once you have met binary and there is something worth building.
The shape
- True and false — a question has two answers, and a table lists them all.
NOTturns one round. - Both, either, different —
AND,ORand the one you have not met, which asks whether two things differ. - Two guards, one guard — proving that a tangled test and a plain one are the same test, and swapping the tangled one out.
Nothing here gates anything. It is a side-path, and a short one. Take it when your conditions start getting away from you.