Program a Human Robot
β¨ Your friend follows your instructions exactly and walks straight into a chair, which is how you find your first bug.
π§° You need
- paper cards with arrows drawn on them
- chalk or tape to mark a grid of squares
- an object to be the target
- a friend to be the robot
- a pencil
β οΈ Clear the floor of obstacles so the robot cannot trip.
π What you will see
The robot only does what is written, not what you meant. A single missing turn card sends it off in the wrong direction. Once fixed, the same list of cards works every single time.
π§ͺ Do it
- Mark out a grid of large squares on the floor and put the target on one square.
- Make cards for forward one square, turn left, turn right and pick up.
- Lay your cards in order to send the robot from the start square to the target.
- Your friend must obey the cards exactly, doing nothing that is not written.
- When the robot goes wrong, find which card caused it and fix just that card.
- Swap roles and run your friend's program.
π‘ Why it happens
A computer follows exact instructions in order and never guesses what you meant. A list of exact steps that finishes a job is called an algorithm, and writing it down as cards is the same idea as writing code. A mistake that makes the program do the wrong thing is called a bug, and finding it by testing step by step is called debugging. Professional programmers spend more time debugging than writing new instructions.
π Now try this
Add a card that says repeat the next two cards twice, and rewrite the same route using fewer cards.
π€ Think about it
A cooking recipe is also a list of exact steps, so what would a bug in a recipe look like?
π§ Ask the Acharya
βA cooking recipe is also a list of exact steps, so what would a bug in a recipe look like?β β ask him and he will explain it from your own chapters.
More for Std 3β5
The Egg That Lost Its Shell
After two days the shell has vanished and a bare, bouncy, see-through egg is sitting in the jar.
Try it βScience20 minBalloon Rocket
Let go of the balloon and it flies the whole length of the room along a string, like a tiny rocket.
Try it βScience20 minLiquid That Fights Back
Your finger sinks in slowly like honey, but a fast punch lands on it as if it were a solid floor.
Try it β