P. 1
Script for Scratch Polygon Creator

Script for Scratch Polygon Creator

|Views: 36|Likes:
Published by Sandra Thaxter

More info:

Published by: Sandra Thaxter on Apr 06, 2012
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less






The purpose of this script is to illustrate the use of the following:1. Project orientated learning. 2. Learning by discovery. 3. Community of Inquiry (COI). For this example, Scratch has been chosen as the vehicle. It is assumed that the students have been made familiar with the computer and with the basic structure of Scratch. The purpose of the project is to implement a Scratch program which will cause the sprite to draw a polygon of any number of sides. The students should have no, or little, prior knowledge of angles and their relationship to shapes, but should have been encouraged to use their bodies to form some different shapes by joining together in groups to form triangles squares etc. They will work on this project as a group with even the most reticent among them being encouraged to supply their ideas at each stage. The approach should be to take seriously even the most outlandish seeming idea and trying to see if it can be made to work. An advantage of this approach is that the least advanced of the students takes part and gets to understand the process and can go back to make sure that they fully understand the results, while the more advanced students can go out of the group for periods to devise and implement projects of their own to avoid their being frustrated. This approach, starting with using their bodies (they can even improvise songs or rhymes as mnemonics) to act out the project as a group, then programming the sprite, can be implanted in learning about adding, subtracting, multiplying, long division, etc., before formal lessons on the subjects.



‘F’ which could be a teacher or a more advanced student helping less advanced students. F: “We are going to design a program which will instruct the sprite to draw different shapes depending on how many sides it should have. and to position the sprite in a known position. the ‘pen up’ block prevents the sprite leaving a trace when it is moved to the start position set by the next ‘motion. than by a linear path to the conclusion. It does not replace Euclidean geometry but helps you to understand what you will be taught in the conventional way. The blocks are all colored and are found in the menus shown below with the same color. We will start with a simple program and work on adding more to it as we progress. don’t know” 2 . the clear block removes all traces of the previous session. and the group of students. To begin with we will do some housekeeping to remove traces of the previous session as we go. blocks” F (facilitator) : “How would you tell the sprite to draw a circle?” G (group) : “…………. This is part of a process of working by trial and error where more is often learned from the ideas which did not work out. ‘G’.This is an imaginary session between a facilitator. Within the dialog ‘……’ represents discussion ending with a decision.. The entry in the computer can be made by either a group member or the facilitator. We will be using ‘Turtle geometry” which differs from the standard “Euclidean geometry” in the important way that it is more natural. The start block causes the following series of actions to take place when the green flag is selected. and the fixing of the errors. A further valuable lesson to be learned is that a given result can be arrived at in a number of different ways. In a real life case there would be cases of backtracking and modification as decisions do not work out.

but not both at the same time. so what shall we tell him to do? Try moving like the sprite”.take a step and then turn” F: “Should it be a big step or a small step?” G: “A small step” F: “And how about the turn. This is done by a number of blocks in the ‘CONTROL’ menu” 3 . G: “……. should he turn a lot or a little” G: “A little” F: “Right let’s try the sizes already set for the ‘move’ and ‘turn’ and drag them out?.Walking” F: “What do you do differently when walking in a straight line and walking round a circle?” G: “…… We turn as we walk” F: ”But the poor sprite can take a step in a straight line or turn.F : “Why don’t you walk in a circle and tell us what you are doing?” G : “…. F: “Now.. we can either repeat ‘move –turn’ over and over or I will show you a POWERFUL IDEA called recursion – you don’t have to remember the name but it means that you do you the same thing over and over again.

F: “But he does it over and over again. and we click on the green flag and he draws a circle”.F: “We will chose the ‘forever’ block for now because we do not know how many times we want the sprite to move and turn”. What do you think – how do you know when you have walked round a circle once?” 4 . So now we need to figure out how he knows when he has finished drawing one circle. F: “We will make the sprite very small so that we can see what he has drawn.

in the scratch display.. The variables are set up as shown replaces replaces the number 15 in the ‘turn’ F: “You will notice that.or we are looking at the same thing as when we started…… we are facing the same way” We can try stopping at a line. as shown in appendix 1. For example.G: “……. this works. Let us be curious and. above the program the sprite position is displayed and it includes the direction” F: “Now.. What should we be curious about?” G: “……. introduce the concept of variables which are names which represent numbers so that the number can be displayed and used in different places while being changed in one place. to do so.how far he has moved……how far he has turned” F: “The variables below” and give us those values. The program and method is based on the following F: “Let us look at the case where we let the sprite go until he is facing the same direction as he was when he started. to get the sprite to stop. let us go back to the circle program and change it by adding variables. The variable the number 10 in the ‘move’ command and the variable command. but has the disadvantage that the end point is not very precise because of the finite size of the sprite. which control should we choose to replace the ‘forever’ block?” 5 .We could draw a line…….

oh yes. he does not move. Why?” G: “…………….G: “……. he is pointing in direction 0 when he starts” F: “What can we do about it?” G: “…….’repeat until’” F: “OK” F: “Oh dear.move him away from that position……let him move and turn before the repeat block” 6 ...

some numbers work and others do not. This number is important.the sprite does not get to face in direction ‘0’” From now on. but only after the group has a chance to grapple with the problem. . or putting in ---. as concepts get more complex. We will illustrate it by trying an experiment with ourselves. I will tell you after you have taken the 10 steps if you are there.take note of which variables change and which stay the same” G: “……. Say that you have to take 10 steps and end up in a place which I have chosen but have not pointed out to you. F: “Now I am going to introduce you to another powerful idea called ‘successive approximations’ which means getting nearer to solving a problem in a number of steps. Why? Try single blocks if you get stuck” -. you have gone too far or not far enough. the facilitator will have to take a more active part in the discussion. Now try different values of . F: “Now do the same with the variable stepping. What size of step would you start with?” 7 .F: “Success!! ---Take note of the value of total degrees in particular.

. it turned F: “Can it go more than G: “……. Now there is a useful series of numbers ‘1. but will do that soon.Yes” 8 that it has just passed the 0 ” as it passes the 0 heading?” .. If it goes too far it will be following the same path as the first time round. 2. 8.G: “………small steps so that we do not get there too soon” F: “So you will gradually take bigger steps until I tell you that you have passed the finish line. each one is twice the one before” F: “Right! Or going backwards. Can you tell me what is special about them?” G: “……. and 16’. how much smaller would you make your step?” G: “…………half way between the last two steps” F: “Right. say 16 each time until we pass then finish line. Let’s think of how we tell that the sprite has gone past the finish point of the circle. 4. we can go back and increase by 16 ÷ 2 = 8 for the next try. which we will call ” F: “For the circle we do not specify the number of sides. How far did it turn at the very beginning?” G: “…. each one is half the next one so that if we make the step bigger by.. Do you all understand that?” G: “…. Now what will you do?” G: “……make the step smaller” F: “If you want to get to the right size in a neat way.yes” F: “We will need a new variable for this number. Now the sprite works in exact numbers so that we would have been adding a number to the move size each time around..no” F: “So can we say that if the heading is greater than 0 and less than heading?” G: “. Can anyone tell us how we know that it has just passed the 0 heading?” G: “…………don’t know” F: “Let me give you a hint.

which we can set to 1 as we do so” F: “We need to go back to the ‘control’ menu to choose a new block. which do we have to set up again every time we start over? 9 . A program which does draw a circle by using successive approximations is in appendix 2 in case anyone would like to work on it. what does he have to do. then we need something more. with this we can say.F: “We will find out later that it useful to know that the sprite has passed through the 0 heading. for example. In fact let us go on to the main object of the project. Try to do it yourself if you like with three sides” G: “…….. It will become clear that it is easy to make sure that the circle is closed once we have found the secrets of the simpler figures. each time he draws the number of sides and finds that he has not got to 0.we don’t know” F: “We are trying to draw figures with different numbers of sides. Does that tell you what the variable to tell the sprite how many sides he should draw is?” G: “. in this case . I can go home. which is a variable. What should it be?” G: “…….. The circle is a special case because it has so many sides.start over” F: “Here is a list of the variables. otherwise We can put these blocks inside one another to get the sprite to do complicated things” F: “Let us put it in. ‘if I it is time to go. For this we need a new variable. we can use that to set 1’ then subtract the new variable ÷ 2. so we set what we call a flag.. but we need to do something else otherwise. ” . can you tell me what it is?” G: “….yes it is ” F: “We also need another variable to count the sides as the sprite draws them and we shall call this ” F: “Now we need to think about what we are asking the sprite to do. so that we need the control (else) I need to stay here’.. We can say ‘if is = F: “Yes. to draw multi-sided figures.

if heading = 0. We start as we have done before. so how do we begin after this set up block? Remember that we do not know how many times the sprite will have to start over” G: “…. with the additional variables” 10 .F: “sides” F: “steps” F: “add” F: “nearly there” F: “degrees” F: “total steps” F: “drawn sides” F: “total degrees” G: “…No” G: “… No” G: “… No” G: “… No” G: “… Yes” G: “…Yes” G: “… Yes” G: “… Yes” F: “OK. else” F: “But how will set the initial position” G: “OK……forever” F: “Right..

F: “What next? Hint – we have to attempt to draw the figure” G: “………last time we repeated until ” F: “And then?” G: “…….if =0 else = 0………….if > 0 and < and ……… Else if =1 ” 11 .no repeat until = ……….

F: “OK let’s try that except to make thing easier to see. set Scratch to the ‘single step’ mode and follow the program step by step until you realize where It goes wrong”. Don’t forget that if things don’t work the first time. 12 . we will move the sprite to a neutral corner both when we stop and when we are ready to start again.

13 .

you will see that the degrees shown for each turn is 120. and what would happen if the sprite turned through both one after the other?” G: “……. This is not the number which you will learn in geometry class. Do you see that there are two sizes of turns between the two sides?” G: “……yes……one inside the triangle and one outside” F: “Right. what do we see and what is the value of degree?” G: “A straight line and 180 degrees” F: “What does the sprite do at the end of the line?” G: “He turns round and goes back to where he started” F: “Now look at a corner of the triangle and see which way the sprite turned from one side to the next – try it for yourself if it helps.. and through how many degrees did we find he would then be turning?” G: ”….he would go back on the first line” F: “Right. What is the difference? Before we figure this out let’s set the sides to 2.180” F: ”So what is the size of the inside angle?” G: “…….. You can add a new variable = 180 to your script and get the inside angle for all the figures” End of script 14 .180 – the outside angle” F: “What is that in numbers?” G: “…180-120 = 60” F: “That is the angle usually referred to for a triangle with 3 equal sides.F: “When you choose 3 sides.

15 . They should end up with differences from the example which should emphasize the fact that there are many different ways to solve a problem. Further related projects would be to modify the as the figures are drawn to see what happens. using the same technique of trial and error. Then motion could be added – get the sprite to draw a stick figure which walks across the screen. It would be a good exercise to investigate the reason why all these figures end up where they began without having a gap. This could get progressively more realistic as the confidence of the students develops.Suggestions for follow up Each student should try to create his own version of this project. but it should be emphasized that this should be by means of hints and not by showing exactly how to get to the next stage. They can help one another in this exercise.

Appendix 1. 16 .

17 .Appendix 2.

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->