Making Choices
Sometimes the next step depends on what you see. If there is a marker, turn left; otherwise go forward. That is a choice.
- Write a rule that picks between two actions
- Explain why the robot must check something before it chooses
- Connect everyday if-then decisions to programs
Finish first
Topic contents
Lesson 1 of 3
If this, then that
You already make choices all day. If it is raining, take an umbrella. Otherwise walk normally. The second part only runs when the first part is true.
In the robot lab, the Choose a path plan says: walk to the yellow marker, turn left, then walk to the flag. The marker is how the plan knows which way to choose.
Without a check, the robot would always turn or always go forward. Choices need a question first: what do I see?
Robot planner
Run Choose a path and watch the robot turn at the marker to reach the flag.
Robot planner
Sequences, turns, repeats and choices- Forward
- Forward
- Forward
Start
The robot starts here, facing right. The plan has 3 steps. It will follow them exactly, even when that is wrong.
Lesson 2 of 3
Two paths, one plan
Run Choose a path slowly. The robot moves up onto the marker, turns left, then reaches the flag. Going straight instead would hit the wall beyond the marker.
Games use this constantly. If the player touches lava, reset the level. If the score passes 100, show a win screen. Same shape as the robot: check, then pick.
Write your own rule: 'If the light is red, stop; otherwise walk.' That is an algorithm you already follow.
Lesson 3 of 3
Choices plus repeats
Big programs combine ideas. A loop might repeat until a goal is reached, and inside each repeat an if-then picks left or right. The robot lab keeps them separate so you can learn one at a time.
When a plan fails, ask: was the wrong branch chosen, or was the check looking at the wrong thing? Fixing choices means fixing the question, not only the action.
Next you will order things without a robot: compare two cards and swap when they are backwards.
Practice
Work these out yourself
No answer key here on purpose: these are the questions worth thinking through before you move on. Open one and work it out.
0/3 attemptedAssessment
Check your understanding
Answer each question, then read the explanation. That is where the learning is.
Finished this topic?
0 of 3 lessons marked done. Marking the topic complete ticks the rest.
