Getting from A to B
Programming Direction - Lesson 3
Objectives
- Give clear unambiguous instructions
- Make predictions when giving instructions
- Create algorithms for directions
- Debug simple programs
Lesson Resources
Lesson 1 - A...maze...ing Instructions
Lesson 2 - Shape Algorithms
Lesson 3 - Getting from A to B
Lesson 4 - Programming Turning
Lesson 5 - Keep Turning
Lesson 6 - Introducing Logo
Introduction
Recap last week’s lesson. What is programming? What is an algorithm? What kind of words did we use to give good accurate instructions to our partners?
Go back to 2Go from Purple Mash and and explain that we will be looking at getting from A to B (From one place to another). Open the maze background and position the mouse in one of the four corners. Ask them to have a go on their own at using the four directional buttons and the numbers to guide the mouse to the cheese.
One step at a time
Then click the purple file menu button and choose 'New'.
Switch to the town background and ask them to work with a partner.
As they did with the shape challenges last week, partner A chooses a start and end point for the car journey, for example ‘Start in the bottom left and go to the purple house’ or ‘Start at the red house and go to the bank’. Partner B tries to guide the car successfully from start to end point without crashing or driving on the grass. Ensure they click on a pen first so their route can be seen. If they go wrong, just correct it with the next instruction.
Swap over and repeat, changing the pen colour each time so the different routes can be seen.
Was it easy or difficult? What’s the hardest part - when to turn? judging the distances? Did anyone think about more than one step at a time? What happened when it went wrong?
When there is a mistake in an algorithm it needs to be fixed so it works correctly, we call this debugging (To look for and correct errors - usually in computer programs or hardware). Computer programmers need to constantly test their work (like video games) to try and find any mistakes and fix them, we need to do the same.
Plan the whole algorithm
So far we have been working on giving one instruction at a time. We’re now going to try to write the full set of instructions (algorithm) for our journey before we test it.
Go back to Settings > General and turn on 'Allow programming' feature.
How have the controls changed now? Point out that new icons have appeared at the bottom of the control panel.
Each one gives a different way to control our turtle.
Click on the second tab and show that we now have a flow diagram.
The third tab gives you a longer flow diagram if they run out of space or want to do a journey with two stop off points. The fourth tab give you the option to add a loop (repeat) function to your algorithm.
We now need to think about the whole journey and make predictions for each part of it. We can drag our instructions into the diagram and test them by clicking on the Play button.
If it doesn’t work, they will need to work out where it went wrong. Which instruction was wrong? Was it the direction or the number? Incorrect instructions can simply be dragged out of the box to delete them.
Ask them to pick a new start and end point and work together to try plotting the whole sequence before beginning. Debug any mistakes until the sequence is correct. Reinforce that it isn’t about getting things right first time, but about being able to find and correct your mistakes.
Plenary
Review how they found this second task: Was it easy or difficult? What’s the hardest part - when to turn? judging the distances? Was it hard to think about more than one step at a time? How did you debug your instructions?