IF
Home Up Paintbrush Graphics The Text Box Callouts etc. Drawing tips Turtle Today IF

How does the robot get out

When you write a program, you can tell the computer what to do, step by step. But sometimes, the action of the computer depends on the situation. A good example is the following (familiar) button.

IF the person clicks YES, --> then the page will be saved.
IF the person clicks NO, --> then the page will not be saved.

Computers are good in choices with two options. They are very simple to follow. When more than two choices are necessary, you need to write more IF statement with two choices:

A series of commands for a screen saver would look something like this:
1) Start time at 0:00 --> go to 2)
2) wait one second --> go to 3)
3) IF there was input from the keyboard or the mouse --> go to 1)
    else --> go to 4)
4) IF time = 1:00 --> go to 5)
    else --> go to 2)
5) start screensaver program --> go to 6)
6) IF input from mouse or keyboard --> go to 7)
    else -> 8
7) stop program --> go to 1)
8) wait one second --> go to 6

Number 3,4 and 6are IF commands. At that time, the computer checks for input and acts according to its instructions.

GETTING OUT OF A ROOM

floppy_disk_walking_md_wht.gif

There is a robot in a square room. There is one door opening in the room, but you do not know exactly where. Write a program so the robot will always find the door, regardless it's starting position.

The computer can sense if there is a wall next to her or in front of her. ("FEEL"). She can turn any direction ("TURN), default 90°. And she can take a step forward (STEP)

For the answer (click here)

Can you write a series of commands, that can be used in a VCR computer chip?
The computer has no clue what time it is, but it can check the time on its clock, with the time on the preset recording menu.
How would the program look that makes sure the computer starts recording at the right time?
REMEMBER THAT EVERY LINE NEEDS TO END WITH DIRECTIONS OF WHAT TO DO NEXT!!
 

Back