Enhancing Computational Thinking with MIT Scratch

0 downloads 0 Views 852KB Size Report
F: calls the draw function by decreasing the number. +: turns clockwise with angle 200. - : turns anti-clockwise with angle 200. [ : stores the current position of x ...
Enhancing Computational Thinking with MIT Scratch and L-System Vinayakumar R, Soman KP Centre for Computational Engineering and Networking (CEN), Amrita School of Engineering, Coimbatore, Amrita Vishwa Vidyapeetham, India Email: [email protected] Abstract In Recursion part1 and part2 paper we have explained and discussed about the basic examples, fractals and various types of curves using recursion. Initially Linden Mayer systems or L-systems were conceived as a mathematical theory of plant development. Originally, I did not include development of plant examples in recursion part 2 papers. This paper explains about the creation of different types of plants. The complete source code and the associated project materials is available in Github [4].

Introduction The beauty of plants has attracted the attention of mathematicians for centuries. The Bilateral symmetry of leaves, the rotational symmetry of flowers, and the helical arrangements of scales in pine cones have been studied most extensively. The developmental processes are captured using the formalism of L-systems. The concept of L-systems is already discussed in recursion part 2 paper. With this the type of L-systems, Bracketed L-systems is introduced to show the development of plant process. Previous studies exist on imparting computational thinking to K-12 education using Spreadsheet [5], [6], [7], [8]. Bracketed L system To generate branching patterns, Linden Mayer added another feature, the stack, a list of positions and directions, and two more symbols, [and], to the alphabet. 1. The symbol [ means to put the current position and direction at the top of the

stack. 2.The symbol ] means to move the current position and direction to the top entry of the stack, and remove that entry from the stack. As an example, we construct a geometric realization of the string

You can understand the different types of grammar symbol meanings from the above figure easily. The grammar is F[+F]-F Step 1: It moves a certain step while drawing. Step 2: when [ appears, it saves the current position and direction to the stack. Step 3: The next symbol is +. It turns by a specified degree. Step 4: The next symbol is F. it moves a certain step while drawing Step 5: The next symbol is ]. So it moves current position and direction to the top entry of the stack (Red line denotes this one only). Step 6: The next symbol is -. It turns by a specified degree Step 7: Finally F appears and it moves a certain steps while drawing. Simple tree example

Fig 1 scripts needed to implement basic tree in scratch using recursion When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the draw function by passing the value 5. The program is written according to grammar, using L-system. The grammar is given below

Here the initiator is F and in each step this f is replaced by generator. The explanation of generator given below. In the place of F, +, -, [,] F: calls the draw function by decreasing the number +: turns clockwise with angle 200 - : turns anti-clockwise with angle 200 [ : stores the current position of x and y and its direction to the list ] : it moves the sprite to the list x, y first element with dir list first element for direction.

Fig 2 output window of tree program 1. Tree

Fig 3 scripts needed to implement the tree program in scratch by using recursion

When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the draw function by passing the value 4. The program is written according to grammar, using l-system. The grammar is given below

Here the initiator is f and in each step this f is replaced by generator. The explanation of generator given below. In the place of F, +, -, [,] F: calls the draw function by decreasing the number +: turns clockwise with angle 25.70 - : turns anti-clockwise with angle 25.70 [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction.

Fig 4 output window of tree program 2. Tree 2

Fig 5 Scripts needed to implement the tree2 using recursion in scratch When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the draw function by passing the value 5. The program is written according to grammar, using l-system. The grammar is given below

Here the initiator is f and in each step this f is replaced by generator. The explanation of generator given below. In the place of F, +, - , [,] F: calls the draw function by decreasing the number +: turns clockwise with angle 200 - : turns anti-clockwise with angle 200 [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction.

Fig 6 output window of tree2 program 3.Tree 3

Fig 7 Scripts needed to implement the tree3 program in scratch using recursion When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the draw function by passing the value 5. The program is written according to grammar, using L-system. The grammar is given below

Here the initiator is f and in each step this f is replaced by generator. The explanation of generator given below. In the place of F, +, - , [,] F: calls the draw function by decreasing the number +: turns clockwise with angle 22.50 - : turns anti-clockwise with angle 22.50 [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction.

Fig 8 Output window of tree2 program 4. Tree 3

Fig 9 scripts needed to implement the tree3 program in scratch using recursion When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the drawX function by passing the value 7.

Here the initiator is X and in each step this X is replaced by generator X, if the X contains F then it is replaced by generator F in each step. The explanation of generator given below. In the place of F, +, - , [,] X: calls the drawx function by decreasing the number F:calls the draw function by decreasing the number [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction. +: turns clockwise with angle 25.70 - : turns anti-clockwise with angle 25.70

Fig 10 output window of the tree3 program 5. Tree 4

Fig 11 scripts needed to implement the tree4 program in scratch using recursion When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the drawX function by passing the value 7. The program is written according to grammar, using L-system. The grammar is given below

Here the initiator is X and in each step this X is replaced by generator X, if the X contains F then it is replaced by generator F in each step. The explanation of generator given below. In the place of F, +, - , [,] X: calls the drawx function by decreasing the number F:calls the draw function by decreasing the number [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction. +: turns clockwise with angle 25.70 - : turns anti-clockwise with angle 25.70

Fig 12 output window of tree 4 program 6. Tree 5

Fig 13 scripts needed to implement tree 5 program in scratch using recursion When the user clicks the green flag, it sets pen attributes, moves the pen to certain specified position i.e. x, y and in certain direction and finally it calls the drawX function by passing the value 5. The program is written according to grammar, using l-system. The grammar is given below

Here the initiator is X and in each step this X is replaced by generator X, if the X contains F then it is replaced by generator F in each step. The explanation of generator given below. In the place of F, +, - , [,] X: calls the drawx function by decreasing the number F: calls the draw function by decreasing the number [: stores the current position of x and y and its direction to the list ]: it moves the sprite to the list x, y first element with dir list first element for direction. +: turns clockwise with angle 22.50 - : turns anti-clockwise with angle 22.50

Fig 2 output window of tree5 program Conclusion: Presently the novice users are being taught only the basic concepts, be it recursion. Recursion is a very powerful technique that can be implemented in one’s daily life as a solution to complex problems. The whole paper explains the importance of recursion in scratch with different types of examples. Beginning with the introduction of recursion in scratch, we demonstrated basic concepts of recursion. Visualization is an effective way and it makes better understanding for the users. In collaboration with the visualization effects and recursion through scratch we introduced the concepts of fractals and curves. To depict deeper concepts of recursion, trees are introduced by using the bracketed L-system. Here we have given the basic idea to implement trees and this will be helpful for the users to implement their own trees. Finally, by reading all these documents in a step by step manner the user can get the clear and better understanding of recursion concept. References

[1] Introduction to fractals, http://classes.yale.edu/fractals/ [2] Graphical modeling using http://algorithmicbotany.org/papers/abop/abop-ch1.pdf [3] Recursion in scratch http://wiki.scratch.mit.edu/wiki/Recursion

wiki,

L-systems, available

at

[4] Scratch experiments Available at https://github.com/vinayakumarr/scratchexperiments [5] K.P Soman, Manu Unni V.G, Praveen Krishnan, V. Sowmya,” Enhancing Computational Thinking with Spreadsheet and Fractal Geometry: Part 1”, International Journal of Computer Applications (0975 – 8887) Volume 55– No.14, October 2012. [6] K.P Soman, Manu Unni V.G, Praveen Krishnan, V. Sowmya, “Enhancing Computational Thinking with Spreadsheet and Fractal Geometry: Part 2 Rootfinding using Newton Method and Creation of Newton Fractals”, International Journal of Computer Applications (0975 – 8887) Volume 55– No.14, October 2012 [7] K.P Soman, Manu Unni V.G, Praveen Krishnan, V. Sowmya, “Enhancing Computational Thinking with Spreadsheet and Fractal Geometry: Part 3 Mandelbrot and Julia Set”, International Journal of Computer Applications (0975 – 8887) Volume 55– No.14, October 2012 [8] K.P Soman, Manu Unni V.G, Praveen Krishnan, V. Sowmya,” Enhancing Computational Thinking With Spreadsheet and Fractal Geometry: Part 4 Plant Growth modeling and Space Filling Curves”, International Journal of Computer Applications (0975 – 8887) Volume 55– No.14, October 2012