Function Machine
Tap a number ball to test the machine, then tap I know the rule and pick one of four rules. Desktop: number keys test, Enter to guess, 1 to 4 to pick, H for a hint.
What is Function Machine?
Function Machine is a free game about what a function is and how to work one out by testing it. A function is a machine: a number goes in, a number comes out, and the same input always produces the same output. You drop numbers into a mystery machine, watch what returns, and then name the rule. The real lesson is that one test proves nothing - put in 3 and get 6 back and the rule could be doubling, adding three, or something else entirely.
How to play Function Machine
Controls: Tap a number ball to test the machine, then tap I know the rule and pick one of four rules. Desktop: number keys test, Enter to guess, 1 to 4 to pick, H for a hint.
- 1Tap a number ball to drop it into the machine's hopper.
- 2Watch the gears and piston work, then read the answer on the glowing output tubes. Every test is written into your test log.
- 3Test another number to be sure, then tap I know the rule.
- 4Pick the rule that fits every test in your log. The machine ticks or crosses each test against your choice.
- 5If your rule fits your tests but is still wrong, the machine runs a test of its own to show you why.
- 6Fewer tests score more points, and Hint suggests a smart number to try next.
Function Machine tips and strategy
- Always test 0 first. It separates adding from multiplying instantly, because anything multiplied by zero is zero while anything added to zero shows you the amount added.
- Then test 1 and 2. If the outputs go up by the same amount each time the rule is adding or multiplying; if the gap itself grows, something is being squared.
- Pick the input that splits your remaining candidates rather than the next number along. Testing 5 after 4 usually tells you nothing new.
- If two rules both fit everything you have, find an input where they disagree and test exactly that. This is how software testing works in real life.
Function Machine FAQ
What is a function in programming?
A named piece of code that takes inputs, does something with them, and returns an output. The defining property is that the same input always gives the same output, which is what makes a program predictable enough to reason about and to test.
Why is one test never enough?
Because many different rules can agree on a single case. If 3 goes in and 6 comes out, doubling and adding three both fit. You only learn which is right by choosing an input where the two candidates disagree - that is the whole idea behind writing test cases.
What is an input and an output?
The input is what you hand the function, the output is what it hands back. In this game you tap the input and the machine shows the output in its right-hand window, which is the same relationship as a function call in any programming language.
What age is Function Machine for?
Around eight and up. The Apprentice mode uses one-step rules like doubling or adding seven and only needs basic arithmetic, while Engineer mode adds two-step rules and squaring, which suits older children and adults.