adding a random turn to BumperBot
In this section, you’ll make a small change to the BumperBot program to make it a little more interesting. Recall that when the TriBot bumps into something, it backs up and turns in a different direction. The distance the robot turns doesn’t need to be any particular value; you simply want to have the robot point in a different direction. You can use a Random block to control the distance the robot turns, which will make the program less predictable.
Figure 14-15 shows the part of the BumperBot program that you need to change. This is the code that runs after the Touch Sensor determines that the TriBot has run into something. The first five blocks make the robot back up, and the final Move block turns the robot. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access