Virtual robotics: the ball-throwing robot → Edition

Dashboard

SHOE

Elementary instructions

Throws all 4 balls in the air
Catches only 1 ball
Display "I've got the small blue ball"
Display "I've got the big blue ball"
Display "I've got the small yellow ball"
Display "I've got the big yellow ball"

Checks

Is the ball caught SMALL?
Is the ball caught BLUE?

Control structures

IF
THEN
ELSE
END IF



Virtual robotics: the ball-throwing robot → Execution

Dashboard

Running the program

Step-by-step execution

Test conditions

Initial test conditions...

Test result

Test result...


The ball-throwing robot : statement

You have to create a program that enables the ball-throwing robot to work properly.

The robot have to throw all the 4 balls in the air and to catch only one of them. The robot have then to display witch ball it have caught.

To do this, you have a number of commands at your disposal that the robot understands:

Your program (code) should be created by dragging the various elements from the "shoe" on the right to the magnetic board on the left. The few basic rules for arranging the various elements (syntax rules) are explained in the "Help" section.

The code you create will be considered correct if the 4 runtime tests are successful together (the corresponding buttons have all turned green).

Good work and good success.

Never forget that mistakes are more instructive than successes,
as long as you take the trouble to understand the causes.

◊ ◊ ◊

The ball-throwing robot: help

Building your program code

All you have to do is drag the various elements provided in the "shoe" and arrange them in the right order on the magnetic board on the left of the screen.

You can always move the elements in this way if you want to change your code.

There is no set order for composing your code; you can start at the end but, in the end, your program will have to comply with the layout rules (syntax rules) defined below.

Syntax rules

By convention, the following elements must stand alone on their lines of code:
- Basic action instructions;
- The "ELSE";
- The "END IF";
- The "REPEAT" (later);
- And the "END WHILE" (later).

Condition structure

To check which side of the coin is visible when it is caught, you can construct a condition as follows.
For line 1, if the face-up side is "Tail", the result will be "True". If the face-up side is "Head", the result will be "False". For line 2 (later), it's the other way round.
Note that the "IF", the Check and the "THEN" have to be in the same line.

Tricks and tips

Before After clicking on number 2
Clicking on a line number in the magnetic board will free up that line so that a code element can be inserted.

To remove an item from the magnetic panel, simply place it on the bin and it will disappear the next time you click on the "Organize" button.

◊ ◊ ◊

© Rupert Meurice de Dormale 2024 (update of the 1995 version)

All rights reserved. Copying in whole or in part prohibited without written permission of the author.

The drawings of the robots are by Jean-Baptiste Sonnet.

adresse