Zmiany

Skocz do: nawigacji, wyszukiwania
[[Plik:B12.pngjpg|center]]
'''Task:''' We ask the students to create and test a script for the Kitten which will draw the trap after it is started. We remind them that we have already drawn a square in class.
''The guidelines should be written down or drawn on the board. After completion we check students’ solutions and, if necessary, help them individually. Should students have problems, we may jointly discuss which blocks can be useful for the task.''
 
 
[[Plik:B2.png|center]]
 
 
'''A sample Kitten script may look like this:'''
 
 
[[Plik:B3.jpg|center]]
 
'''Task:''' We ask the students to add a Cheese script – after starting the programme the Cheese is always set in the middle of the trap, but away from the Kitten. On reaching the Cheese the Mouse should not get caught by the Kitten.
 
''Adding the Cheese script should not take much time, because students have already added the appropriate blocks in the Kitten script.''
'''A sample Cheese script may look like this:'''
 
 
[[Plik:B4.jpg|center]]
 
'''
Discussion:''' We introduce students to the next task – controlling the Mouse. We want the Mouse to move automatically towards the Cheese as soon as the programme is started. We need to discuss how we can achieve this and what will happen depending on the following events (we write down key discussion findings on the board):
 
* The programme is started
 
''The Mouse should be set in the starting position. Then it should repeat the following actions: rotate in the direction of the Cheese, move by a certain number of steps and see if it has reached the Cheese or the Kitten, or if it is touching a wall. If it has not reached the Cheese or the Kitten, it should always repeat the activities from the moment of rotating towards the Cheese. The number of steps should be small so that the Mouse does not pass through a trap wall – otherwise our programme will not work properly.''
 
*The Mouse is touching the Cheese
''The Mouse can say something, e.g. “Tasty cheese” and the programme ends''
 
* The Mouse is touching the Kitten
 
''It can say “Ouch, the cat has caught me!” and we end the programme''
 
* The Mouse comes to a trap wall (touches it)
** ''It should think e.g. “Hmm... How can I get to the cheese?”''
** '''''It should somehow bypass the wall.'''''
 
''Together with the students we come to the conclusion that they are able to programme the first three events. If necessary, together we can select blocks useful for the task, but it is better that this part of the programme is completed by the students on their own.
What does require discussion is the task of '''Bypassing the wall'''. We discuss with the students what the Mouse should do to be successful when it encounters a wall. We should come to the conclusion that if whenever it reaches wall it goes back as many steps as it came forward, then turns right (by 90 degrees to go parallel to the wall) and goes a few steps forward, it will always eventually bypass the wall and avoid meeting the Kitten.''
 
 
[[Plik:B5.png|center]]
 
 
'''Task:''' We ask students to create and test a Mouse script in accordance with the guidelines which have been written down.
 
 
[[Plik:B6.png|center]]
 
 
'''A sample Mouse script may look like this:'''
 
 
[[Plik:B7.jpg|center]]
 
 
===Adding randomness to the Mouse’s movements===
'''Time to complete this part: about 30 minutes'''
 
We note that this version of our programme always works in exactly the same way – the Mouse reaches the Cheese regardless of the starting position.
'''We ask the following question:''' What can we do to make our programme less predictable – to allow the Kitten to sometimes catch the Mouse in the trap which has been set?
''Various ideas may be provided. We hint that the Mouse should try to turn left, and at another time right, because it is not certain where the Kitten is (at the top or the bottom). We ask on what basis the Mouse can make such a decision not knowing on which side the Kitten is waiting. We can refer to a situation in which e.g. before a football match it needs to be decided which team will begin the game. In such a case a coin toss is often used, i.e. a form of drawing.''
 
'''Task:''' We ask our students to find a block associated with such a drawing.
 
[[Plik:B8.jpg|center]]
 
'''We ask the following question:''' From what pool of numbers should we draw? What should we make this dependent on?
 
The Mouse can turn left or right. That’s why we should draw one of two values – e.g. 1 or 2. Then we can assume that 1 means turning right and 2 turning left. We think about how to decide after a value has been drawn. What blocks can we use for this?
''The students will come to the conclusion that the block '''if''' will be useful. However, a better solution would be to use the block '''if... otherwise'''. There remains the problem of what to insert in the if condition. Students will probably come to the conclusion that it should be the result of the drawing. However, it should be compared to a determined value (e.g. 1). Together with the students we create and explain the part of the script responsible for the drawing and selection of the direction in which the Mouse is to rotate. We pay special attention to comparing the values providing '''true''' or '''false''' as feedback.''
 
[[Plik:A2.jpg|center]]
 
''The modified script part should look as in the below illustration.''
[[Plik:B9.jpg|center]]
 
 
Task: We ask the students to modify the script and introduce the principle that when the Mouse touches the wall a drawing takes place to determine which way it should turn. We also ask them to test the programme.
''The effect is almost always the same. The Mouse is stuck by the wall. We discuss why this is so. We reach the conclusion that the Mouse, as a result of drawing which way to turn whenever it touches a wall, ends up spinning in the same place (because it rotates once to the left and once to the right). Together with the students we think about what should be done to allow the Mouse to go further. We reach the conclusion that already at the beginning it should decide which way to turn if it bumps into a wall. It must somehow remember this decision. That is why it will need some memory. Computer programmes store various things using variables, so we will learn how to use them. We can compare a variable to a drawer in which we place something to be used later on.''
'''Task:''' We ask the students to got to the '''Data''' category of blocks, and then create a variable called '''left or right'''. For this purpose they should select the '''Create variable''' button. They should enter left or right in the '''Variable name''' window.
 
''If there are questions about whether the variable should be available only for this (currently selected) sprite or for all sprites , we ask students to leave the default option for all sprites.''
 
[[Plik:B10.jpg|center]]
 
 
We discuss with the students what new options appeared in the variables, and how we should modify the Mouse script now. Together we come to the conclusion that drawing should take place immediately after the programme is started, and its result should be stored in the '''left or right''' variable by setting its value. It is also necessary to change the decision-making part – instead of drawing, the variable '''left or right''' should be inserted there for comparison.
 
'''Task:''' We ask the students to make changes to the script, and then test the programme a few times.
 
'''A sample corrected Mouse script may look like this:'''
 
 
[[Plik:B11.jpg|center]]
 
 
===Suggested additional tasks to be self-completed by students ===
 
 
1. A drawing determines the Kitten’s position at the trap (at the top or at the bottom of the trap).
2. We add the support of L and P keys changing the direction in which the Mouse is to turn, and G and D keys controlling where the Kitten is to wait for the Mouse.
3. We change the Kitten script so that it moves randomly up and down along the left edge of the screen.
181
edycji