Course Scope

Sequences / Creating a sequence of instructions

Operational objectives, the student:

  • determines directions and establishes the position of the hero in relation to oneself, as well as in relation to other objects, distinguishes left and right, top and bottom,
  • understands the concepts of vertical and horizontal,
  • arranges a sequence of instructions for the virtual robot using blocks with directional arrows,
  • reads a sequence of instructions written using blocks with directional arrows,
  • avoids obstacles in the form of maze walls.

Creating sequential code is one of the basic techniques of algorithm design. When we solve a problem in which we can predict all situations that may occur and solve the task in the form of sequentially following program instructions, then the most basic technique is to write down all the actions that must follow each other. This procedure is called creating a sequence of code instructions, in short, creating a sequence. This approach is sufficient for many simple algorithmic tasks, consisting of several or a dozen instructions to perform. This approach is also easily assimilated by preschool children, as it can be related to situations known to the child from everyday life, e.g. going for a walk, cooking soup, etc.

In the Go Lumi! application, sequences of instructions are constructed by arranging in one horizontal line blocks with instructions navigating the robot - go right, go left, go up, go down. Launching a correctly prepared sequence of robot movements will allow the robot to be led from the starting field, i.e. the initial position of the hero on the board to the finish field, which in the application is a hole, sometimes covered with a hatch.

As part of the Go Lumi! course, ten introductory exercises (levels 1-10) are prepared, and in total there are one hundred and ten tasks in which we create sequences of instructions for the robot, using various programming techniques that we learn during this course. The difficulty level of the exercises increases with each subsequent task.

An example of a low complexity task is shown in the Figure: Sequences - Level 2.

Figure: Sequences - Level 2

In the above task, the sequence consists of three instructions, which sequentially indicate the direction of travel to the robot. The task has one correct solution. Theoretically, a longer sequence of instructions could be arranged by adding unnecessary return driving commands, but this would not be an optimal solution. Remember that we are looking for the shortest sequence of instructions that will lead the hero to the finish.

An example of a higher complexity task is shown in the Figure: Sequences - Level 10.

Figure: Sequences - Level 10

In the above solution, the code sequence consists of eleven instructions. The task has more than one correct solution.

Conditions / Conditional Instructions

Operational objectives, the student:

  • applies in the sequence the conditional instruction "if you are on a field marked with blue color, then change the direction of driving".

Conditional instructions (in short Conditions) allow for the execution of certain parts of the code (sequence of instructions) only if a certain situation occurs, i.e. the condition is met. Conditions in programming languages take the form of additional code instructions of the type if, then, which should be placed in the designed algorithm. For the conditional instruction, you need to specify the condition that this instruction will check. If the condition is met, a certain sequence of code will be executed, which should be defined within the scope of the condition, limited by the beginning and end of the scope.

Due to the specifics of the robot's movement in the Go Lumi! application, which after receiving a driving instruction in a certain direction, always goes to the end of the corridor, changing direction in other places (e.g. at branches in the middle of the corridor) is possible thanks to the use of conditional instructions. For this purpose, decision fields, so-called conditional fields, were introduced on the boards, where a decision can be made to change the direction of driving. These instructions take the form of the expression if you are on a field marked with blue color, then change the direction of driving.

To force the user to use conditional blocks (decision-making), the boards were designed in such a way that they cannot be correctly solved without using these blocks. If the block with a conditional turn is not used, Lumi will continue its direction of driving until it encounters an obstacle, e.g. in the form of a wall.

As part of the Go Lumi! course, ten tasks introducing this issue (boards 11-20) are prepared, and in total there are seventy exercises using conditional instructions and other programming techniques.

An example task (Board 11.) requiring the use of a conditional instruction to change the direction of driving is presented below.

In the above task, the change of driving direction from go right to go down is possible thanks to the use of a conditional block marked in blue. The task has more than one correct solution.

An example of a complex task (Board 20) is shown in the figure below. This task has at least two correct solutions.

The above solution requires the use of several conditional instructions. There is no need to use all the blue decision fields in the sequence.

Below is another solution for the same task (Board 20).

In the above solution, all decision fields were used.

Actions / Pick up and drop

Operational objectives, the student:

  • determines the relative position of objects on a plane,
  • applies the Pick up action in the sequence of instructions,
  • applies the Drop action in the sequence of instructions.

Actions in programming take the form of additional instructions - code blocks - with predefined functionality. You can think of actions as certain facilitations - built-in functions, i.e., sequences of code that have been previously prepared and saved in the form of a single code block. This approach greatly streamlines programming because it gives the programmer a set of "tools" to start with, which can be used to solve the actual task. Actions are often provided as components of the work environment (so-called function libraries), which are known at the start of solving a given task.

In the Go Lumi! course, it is assumed that such actions, which are known and available for use, are the predefined capabilities of the robot - lifting objects and placing/dropping them. The prepared exercises assume access to the Pick up and Drop actions.

To enforce the use (practice) of these actions by the student, tasks have been prepared in which it is required to transfer a virtual object to indicated places. The objects are at the end of the corridors - paths, where by definition the robot's movement ends and it waits for the next instruction.

As part of the Go Lumi! course, ten tasks introducing this issue (boards 21-30) are prepared, and in total there are fifty exercises using the Pick up and Drop actions and other programming techniques.

An example task requiring the use of the Pick up and Drop actions is shown in the figure below (Board 21).

In the above task, the robot has one item to transport. Actions for the robot have been defined in the sequence with additional blocks: Pick up and Drop.

A more complex example task (Board 26) with the Pick up and Drop actions, requiring the transfer of two items to their destination, is shown below.

In the above task, Lumi has two items to transport. For each of the items, green blocks with the Pick up and Drop instructions were used.

Iterative Loops / Repeating Sequences in a Loop

Operational objectives, the student:

  • Identifies in a long sequence the repeatedly occurring subsequence
  • Arranges a sequence of instructions using an iterative loop

An iterative loop (sometimes referred to as a counter loop) is a programming technique that allows for the repeated execution of the same instructions, without the need to list them all sequentially. This approach is particularly useful where repetitive code fragments occur side by side within the full sequence of code. Good practice is to look for rhythmic parts of the code, identify a single repeated pattern in this fragment; isolate it as a separate block of code and determine how many times it should be executed. This is possible thanks to the Repeat (Loop) instruction, where you can indicate how many times the program should execute a given sequence fragment. When using the Repeat instruction, remember to set the range, i.e., the beginning and end of the sequence to be executed in the loop. In practice, such a range starts right after the Repeat block and ends on a special block indicating the end of the loop (End-Loop).

Due to the specific movement of the robot in the Go Lumi! application, which always goes to the end of the corridor after receiving a driving instruction in a certain direction, identifying repeated movement sequences is not always obvious at first glance at the board. It turns out that the length of the corridor does not matter here for determining the sequence of movement directions in the loop, as we do not count individual steps-fields on the driving route.

As part of the Go Lumi! course, ten tasks introducing the concept of an iterative loop (levels 41-50) are prepared, and in total there are forty exercises using the iterative loop and other programming techniques.

An example of a board (Board 41) introducing the concept of an iterative loop is shown below.

In the solution above, the loop range is marked with two red blocks. The start of the loop is marked with the 'Repeat 2 times' block, and the end of the loop range is marked with the 'End of loop' instruction block. The number of repetitions, or iterations, is 2 and this is specified in the block with the start of loop instruction.

An example of a board (Board 50) with a more complex task involving two iterative loops (Board 50) occurring consecutively is shown below.

In the solution above, the loop ranges are also marked with two red blocks. The number of repetitions, or iterations, in each loop is 3.

Functions / Defining Functions

Operational objectives, the student:

  • can extract the largest repeatable sequence from a long sequence,
  • knows how to change a code fragment into a function,
  • arranges a sequence of instructions with a function call.

Defining functions is a technique in programming that allows you to separate those sequence fragments that repeat in different places in the code, and then record them in the form of separate instruction sequences (separate code).

The additional defined sequence receives its name, which allows you to use the defined function in other places in the program code. By inserting a block with the function name in the program code, similar to the action block, we 'call the function'.

Additionally, by combining functions with iterative loops and conditional instructions, the programmer can create short and clear program code that is easy to further develop. Using functions also facilitates making changes, fixing errors in the code, and collaborating with other programmers, as it is easier to analyze smaller code fragments enclosed in functions than one long sequence of code solving the entire task. The change that we introduce in the source code of the function is available and the same for all source codes of programs that use this function.

As part of the Go Lumi! course, ten tasks introducing the concept of defining functions (levels 71-80) are prepared, and in total there are forty exercises using functions and other programming techniques.

Example task (Board 71):

The above task has more than one solution. The use of functions shortens the main code sequence. In the solution, you can also use an iterative loop, which will call the F2 function three times.