How to learn to program in a simple and funny way. Learn2program

The DEMETER I language

The DEMETER language has been divided into two parts, DEMETER I and DEMETER II. The DEMETER I language will have simple commands while the DEMETER II language will have more complex orders.

Important: Do not write two or more statements in the same line. Every statement has to be in an independent line.

We are going to start working on the simplest orders, which are the sequential statements. Below are three very simple commands that we are going to give the robot, such as turn right and left and move forward.

Sequential statements

Let’s see these orders in depth:

  • TR statement:
  • TR -TURN RIGHT

Action: The rover will turn right. The rover will turn right within the same square.

 

  • TL statement:
  • TL – TURN LEFT

Action: The rover will turn left. The rover will turn left within the same square.

 

  • A statement:
  • A – ADVANCE

Action: The rover will advance one square

Therefore. The program:

  • A
  • A
  • TR

The rover will advance two squares and turn right.

 

Iterative statement

To solve practically all the exercises that are going to be proposed, iterative statements (while or for) will be needed. These types of statements exist in all programming languages and even in scripting languages.

Only these two types of statements will be seen in DEMETER I since students have to use simplified tools.

The first statement is the while statement:

  • WHILE statement:
    WHILE NB
    [other statements]
    END

Action: DEMETER rover will do [other statements] while there is nothing blocking it.

 

The rover will not be able to leave the minefield except through the entrance. Therefore, the rover will crash at the limits of the minefield.

The next statement is the for statement:

  • FOR statement:
    FOR X
    [other statements]
    END

Action: DEMETER rover will do [other statements] X times, where X is a number.

 

Once we know the language we can solve exercises like the following:

In this exercise the objective will be to enter the minefield and exit through the exit in the least number of steps.

exercise 1

 

Mines and obstacles

For the student to use the most appropriate statements and the challenges to be more fun, the boards will have mines and obstacles. In the following minefield you can see how the mines have been placed in the minefield:

For the rover, an obstacle can be the limit of the minefield or also blocks like the ones that can be seen in the following figure:

All exercises will use the same minefield. However, in the DEMETER I and II language we will use obstacles, mines and other resources to make the programming more complex.

 

The Demeter Project