Activity · Ages 7–14
Build an Algorithm: Teach Spark to Find the Apple
An algorithm is a list of exact steps, in order. Build one below: give Spark the robot a list of instructions, press Run, and watch it follow your list exactly — even when that means walking straight off the grid.
How to play
- Look at where the apple is. Spark starts at the bottom of the grid. Work out how many squares forward it needs to go, and which way it needs to turn.
- Add your instruction blocks. Press Forward, Turn left, Turn right and Pick up to add blocks to the numbered list. Press a block in the list to remove it.
- Press Run. Spark follows your list one block at a time, in order, exactly as written.
- Fix what went wrong. If Spark misses the apple, walks into the rock or steps off the grid, change a block and run it again. Finding and fixing the mistake is called debugging.
Keyboard: click the grid once, then use ↑ for forward, ← and → for turns, G to pick up, Backspace to remove the last block and Enter to run.
What just happened?
You wrote an algorithm: a list of exact steps, in a fixed order, with no guessing allowed. Spark did not work out what you meant. It did what you wrote.
That is the single most surprising thing about computers, and it catches everybody out at first. If Spark walked into the rock, Spark was not being stupid — your instructions genuinely said "walk forward", and forward is where the rock was. The computer was right. The instructions were wrong.
When you spotted the mistake and changed a block, you were debugging. Professional programmers spend more time debugging than writing new instructions. Getting it wrong the first time is not a sign you are bad at this. It is the job.
Three things this teaches
- Order matters. "Turn right, then forward" lands somewhere completely different from "forward, then turn right". Same blocks, different algorithm.
- Computers do not fill in gaps. A person told to "get the apple" would walk around the rock without thinking. Spark needs the going-around spelled out, step by step.
- Shorter is not always better. There is a shortest answer to each challenge, but any list that gets the apple is a correct algorithm. Try to find the short one after you have found one that works.
Why this matters for superintelligence
Spark grabbing thin air is a tiny, harmless version of a problem that AI researchers take very seriously. The machine did what you said instead of what you meant, and the gap between those two things is where almost all AI trouble lives.
Today's most advanced AI is not given step-by-step blocks like these — it learns patterns from huge piles of examples instead, which you can try on how does AI learn. But the underlying worry is the same one you just met on a 5×5 grid: a system pursuing exactly what it was told, and nobody noticing the instruction was slightly wrong until it has already acted.
Making sure a powerful AI understands what people actually mean is called alignment, and it is the subject of is superintelligence safe? — where a too-literal wish machine makes the same mistake Spark just made, with much bigger consequences.
Make it harder (no screen needed)
- Write it down first. Before touching the buttons, write your list on paper. Then run it. Were you right?
- Beat the block count. Each challenge tells you the shortest possible answer. Can you match it?
- Be the robot. One person writes instructions on scraps of paper — forward, turn left, turn right, pick up. Another person is the robot and may only do exactly what the papers say. No guessing, no helping. It gets funny fast, and the lesson lands harder than any screen.
- Break it on purpose. Can you write a list that makes Spark walk off every edge of the grid in turn?
For grown-ups
This activity covers sequence, precise instruction and debugging — the core of UK KS2 computing (design, write and debug programs; use logical reasoning to predict behaviour) and a useful warm-up for KS3. It needs no account, stores nothing, and runs on a school tablet. There are printable one-page summaries and discussion questions on the parents and teachers page.
The natural question to ask afterwards is not "did you get the apple?" but "where did Spark do exactly what you said instead of what you wanted?" That question is the whole lesson, and it is the same question AI safety researchers ask about far more powerful systems.