I’m going to be a Bot (robot), and you can be the Developer who writes programs for me.
If you’ve made badges, you can wear the “Bot” one, and give your helper the “Developer” one.
For me to move on the grid, you can only give me three instructions; forward, left and right. How do you want to write those instructions down?
Decide what symbols you will use to write the instructions (what “programming language” you will use). We suggest arrows (↑, ↰, ↱) or letters such as ‘F’ for ‘forward’, ‘L’ for ‘turn left’.
Here’s how the three commands work.
Practice what each instruction means. ‘Forward’ means step forward into the square directly in front of you. ‘Turn left’ means pivot 90 degrees left on the spot, but stay in the same square. You can demonstrate each of these moves. (Don’t point this out explicitly to the developer, but ‘Turn left’ and ‘Turn right’ keeps you in the same square; it’s more fun if they realise this later!)
This is my starting square, and you need to give me instructions to get to the ball [or whatever object you want to get to].
You can decide on a start and an end position (here the ball is in the end position). The kind of distance shown here (a few squares forward and a few to the right) is good to start with.
Your challenge is to write instructions for me to follow to get to the ball.
The developer writes the instructions (program) for how to get from the start position to the end position i.e move the bot to the ball. They then give the instructions to the bot, who follows them - this is referred to as “running” the program. (Chances are that their first attempt won’t work; the attempt shown here is a typical one with the RRRR causing the Bot to turn on the spot). Do not start moving until all the instructions are written. As a bot, you should always go back to the starting point, and follow the whole “program” each time; ignore any mid-course requests for changes!
(If you don’t get to the correct square) Nice try, but you need to debug your program!
It’s normal for computer programs to need debugging - a bug is simply when it doesn’t do what was wanted. This is a chance to introduce and use the term whenever the program is wrong. Enjoy errors such as sequences of turns that have you spinning on the spot! The developer can mark on the instructions (program) where any bugs (mistakes) are found. Remember, it is good to find mistakes as then you get to debug (fix the mistakes). You could even make up a bug finding celebration dance if you like.
(Once they get the correct answer). Well done, you’ve written a program that gets me to the right place.
Is there another program you could have given the bot to get to the ball? Write the instructions/program for that route.
Follow the new instructions once they are written.
What’s a long set of instructions to get the bot to the ball?
The developer may enjoy having the bot go around in circles, but they have to be careful to get the instructions just right! It’s good to reinforce the idea that there are multiple ways to write a correct program - in fact, the task has an infinite number of correct solutions! It also has an infinite number of incorrect solutions!
Tip: If your child finds it hard to visualise how the arrows work, place the arrows within the grid to show what the bot will do. It’s also a great technique to write the first few instructions of the code, test it and then add to it (consider placing a toy on the grid to remind them where their initial instructions got the bot to). If you are putting arrows on the grid, the turning arrows will also need a forward arrow in the same box, or you can put the forward arrows on the line between boxes, which makes it clearer what it does.
There are many ways to extend this challenge. You can add in obstacles that must be avoided. It is also instructive to reduce the possible instructions to only “Forward” and “Turn left”. With some thought, it’s still possible to get to any position on the grid without the “Turn right” instruction!
A key point in this activity is that the instructions are all written before they are tested. We don't allow anyone to give additional instructions to the Bot; they must follow exactly what is written (which can sometimes be humorous if they head off in the wrong direction.) This is what happens when programming: you write instructions for a program, and when you run the program, they are all executed without the programmer intervening. A programmer needs to picture in their mind what would happen when they are writing the instructions; during testing they will find out if what they pictured was correct!
Creating a sequence of instructions a computer or robot can follow is an important skill in programming. Like all skills, programming is something you learn through practice, making mistakes, and learning from them. Another important skill that programmers need is to be able to communicate with others, especially when they are working out what the program should do. They also need to be persistent when finding and fixing bugs. Bugs happen all the time in programming, so being able to identify where the bug occurs and problem solving how to fix it is incredibly important. It doesn’t matter how experienced you are at programming, there will always be bugs that need to be found, and fixed. That’s why being prepared, and able, to debug is so important.