Rescuer Learn 4: Logical Decisions

This is the third challenge within the Robotics with GoPiGo and Python Curriculum.

Your task is to design a robot program that can navigate through the maze-like jungle without trampling over any plants or getting stuck in any dead ends.

Learn how to use the Distance Sensor and practice using the left-hand rule of maze-solving.

1. Making Logical Decisions

Set the robot aside for a moment and let’s discuss logical decision making. We’ll get back to the robot very soon.

Imagine that you want to watch a film on the TV. You press the power button on your remote control but nothing happens. You then realise that the TV is not plugged in. You plug it in but it still doesn’t work. It’s only then that you remember that you recently borrowed the batteries from the remote control for your new remote controlled toy. D’oh! Off you go to retrieve those batteries.

The TV is now on and the popcorn is made. Let’s now find a film to watch. You fancy watching some science fiction or comedy. You flick through your film library for film that fits the bill. Wouldn’t it be great if you could find a film that is both a comedy and science fiction such as “Men In Black” or “Back to the Future”? However, you’re not fussy. You’ll watch anything from either genre.

In the scenario described above, the TV will only power on when all of the pre-conditions are met and you will choose a film that meets any of your genre criteria. Let’s describe these situations in pictures.

In the computing industry, we call these truth tables. To determine an outcome, simply read off the value in the cell that is in the row and column that matches the answer to both of your questions. 

LEFT TABLE:

When a positive outcome requires all conditions to be met, we use an AND table. It is called this because the end result can only happen if condition A  AND condition B are true. 

RIGHT TABLE:

When a positive outcome only requires any one of the conditions to be met we use an OR table. It is called this because the end result can also happen if only one of condition A OR condition B is true.