Programming for prospective educators (using Scratch) - unit 4

Aus ZUM-Unterrichten


| ⇠ back to main page | ⇠ unit 1 | ⇠ unit 2 | ⇠ unit 3 | unit 4 |


==Guidance for students (Open Document Format ODF)==

Handout for teachers

Objectives
  • The students shall understand a simulation as a way of searching a solution for a problem.
  • They will analyse and test the provided example of the simulation of a robotic lawnmower.
  • The students supplement the simulation example with an algorithm that they will develop on their own.
  • They shall understand the block concept as a means to clearly outline programs.


Introduction

A computer simulation is a program that models a system (e.g. the streets in a neighbourhood with high traffic volumes) and shows (often with a visualisation) how the simulated system behaves under different conditions (e.g. if speed limit 30 was introduced, or if some streets were converted to one-way streets). Computer simulations are useful, for example, when experiments with the real system of interest are too costly, too dangerous or even impossible. And even when experiments are possible, comparison with simulations often helps to better understand the behaviour of the individual components of a system.
In this unit, the students analyse the example of a simulation program for a lawn mowing robot. They supplement the program with a self-developed algorithm that causes the robotic lawnmower to "return" to its box at the end of the simulation. The students learn about and apply the concept of structuring programs with blocks.
The lesson might be started with an advance organiser: Who knows of robotic lawnmowers or hoovers from experience (at home, from neighbours, etc.)? Do these robots mow or hoover the lawn or room completely, right down to the last corner around all obstacles? Can this be proven, estimated or verified? What do you think about a simulation?


Getting familiar with the example program


BildschirmaufnahmeMähroboterSimulation.png


For this unit, the students need the program (project) "RobotLawnMowerSimulation-Template". It is published on the Scratch platform and can be downloaded from there to one´s own computer: https://scratch.mit.edu/projects/878189075/
The program simulates a robotic lawnmower on a plot of land with shrubs. When the lawnmower touches an obstacle (a shrub, the edge of the plot), it backs up a bit and then rotates through a random angle between 15 and 30 degrees. Then the lawnmower continues straight ahead until it touches another obstacle.
The students should start the program several times and take a screenshot of the simulation result. When the students compare the paths of the lawnmower, they should realise that the results differ and understand why this is so.
Although the simulation always ends after the same number of steps (the algorithm is terminating), the result of the program is always different. The result of the program execution is non-determined: In each simulation, the paths are different and the robotic lawnmower ends up in a different place.
But is the algorithm at least robust, i.e. does it still work reliably when the execution conditions change?
The students must understand what an algorithm is. They need to take note of the terms terminating, non-determined and robust. Thus they should become aware of the fact that an algorithm does not necessarily always give exactly the same solution when one runs it several times.
The students should modify the program in order to assess the results of the simulation under different conditions. For this purpose, they place an additional obstacle (house) on the "plot of land" .
The students must adjust the relevant execution condition in the block "Mowing" so that the robotic lawnmower recognises the house as an obstacle.


CodeSequenzHindernisErkennen.png


Perhaps the students need support in this step. They should make sure that the robotic lawnmower doesn't "mow through the house".

The block concept for the structuring of programs

The script of the simulation program is very simple.


SkriptSimulationsprogramm.png


The script comprises two blocks: "Initialisation" and "Mowing". The individual commands for the initialisation and the control of the robotic lawnmower are defined as separate blocks. The division into blocks makes the program easy to understand.
The students should realise that programs structured in (script-) blocks are clearer and easier to understand. They should therefore implement the following extension of the simulation program using a block.


Extending the algorithm to control the robotic lawnmower

The lawnmower stops somewhere after the number of given steps. However, the lawnmower should drive back into the box in the end.
The students shall design an algorithm that leads the lawnmower back to the box and define the block "returnToBox" for this purpose.
This is not a trivial task. The algorithm for the return of the lawnmower to the box must, like the algorithm for mowing, make it possible to "go around" obstacles. While the algorithm for mowing is non-determined, the algorithm for returning to the box must always deliver the same result, i.e. it must be determined. Therefore, the algorithm for mowing cannot simply be copied. Using this example, the students can discuss very basic considerations about algorithms.
The students should test their algorithm. It might be helpful to discuss possible test strategies with the students beforehand. The lawnmower stops at a random position at the end of the simulation. Would a few attempts be enough to test the algorithm for returning to the box? Or would it be better to position the lawnmower "by hand" at a few selected points and test whether it returns to the box with the self-designed algorithm?
In any case, the fundamental question regarding the correctness of programs is raised (once again) in the final reflection.


Reflection
  • Discuss the usefulness of the simulation from the point of view of …
- a company offering robotic mowers and
- a person who wants to buy a robotic mower.
  • Probably in none of the completed simulations the "lawn" has been completely "mowed". Do we have to accept that even with computers, completely satisfactory solutions cannot be found for all problems? Do we have to give up warranties for programs?
  • Are you aware of other areas of applications where simulations are useful or even necessary?
  • Discuss possible risks that could arise when we transfer simulation results to reality.



Authors: Bruno Wenk, Dieter Burkhard

Translation: Patricia Berchtel