Page 44 - Ai Robogenius
P. 44
If the robot tries to do these steps
in the wrong order, like trying to SMART Ai-Da is a smart robot that can draw
release the part before picking SPARK and paint. It learns by looking at pictures
it up, the part might fall or not and then makes its own artwork.
reach the belt at all.
LOOP
Sometimes, robots need to do the same thing
again and again. A loop helps the robot repeat
the same actions automatically, so you don’t
need to tell it every time.
Imagine a robot that needs to sweep the floor.
Instead of telling the robot to move forward,
turn left and sweep the floor three times, you
can use a loop. This makes it much easier to program the robot.
For example, the following instruction can be given to the robot to clean the floor:
Repeat 3 times:
If a robot sees someone getting hurt,
Move forward
should it stop and alert a human for
Turn left help immediately to ensure safety?
Sweep the floor
By using a loop, the robot will repeat the given three steps three times without you
having to write them out each time. This saves time and makes the program simpler.
VISUAL VAULT
Guide the robot to move from its starting point to the Star, by following the
given code:
Start
Repeat 2 times:
Move forward 1 step
Turn right
Move forward 1 step
Stop
AI RoboGenius - III
42

