Skip to main content

Learning Scratch (2)

My last blog entry, I briefly talk about what is Scratch. There are ``events'' and that is the trigger of the program. In this article, I would like to talk about one of my students who made a character animation program by Scratch.

Scratch provides key events. When I push the right arrow key, then ``right arrow key push event'' is triggered. When that event happened, I add 10 to the x coordinate of the cat. This means, when the right arrow button pushed, the cat move to the right for 10 steps. If I add more programs like the up arrow moves the cat to upper direction, I can control the cat position by the arrow keys. This is a cat control program.

Today, my student used a dragon. He wrote the same program with the cat. Then, the cat and the dragon move exactly the same way. Of course they should. A current computer is very fast, very precise, and very stupid. It does only what the developer wrote. My student asked me, how he can make the dragon faster. I answered, increase the moving step. Currently one key push moves the dragon ten unit steps. A speed is a moving distance in a certain time. If the step was increased to twenty from ten, the speed of the dragon becomes twice. While after, when I came back to him, he duplicated the key events. Interesting.

His method is the following: when the right arrow push event was triggered, two programs started in parallel. One program change the dragon's x coordinate plus 10, and another program does the same. In the end, the dragon's x coordinate increased by twenty. It seems the Scratch environment takes care the parallel change (i.e., locking), so this program works correctly. When he wanted to move the dragon three times faster than the cat, he copied the program again. What an interesting idea he had! Out of the blue, I recalled one scene of a cartoon, JoJo's Bizarre Adventure. (If you don't know it, please ignore the rest of the paragraph.) It's a scene that Jotaro floated in the air using his stand. He can move in the air by pushed his stand. My idea was increase the speed of the stand, but my student idea was increase the number of stands. Two stands can push twice faster, three stands can push three times faster.

But this student's idea can only make whole number times speed. He cannot make the dragon 1.5 times faster than the cat. Of course one program can push the dragon ten steps and another program can push the dragon five steps, make it 1.5 times faster. But then, there is not so much difference from one program pushed fifteen steps. His idea is just coping all the events and nothing more, still he can change the speed twice. However, if you learn the idea of generalization from mathematics, you will realize that which method can be applied to more situations. In this case, changing the speed itself in one program is better since you are not limited to multiple of positive integer (not only fractional times speed up, but you can stop and can also go backwards). If you learn computer science, the one program is considered better since the resource consumption of multi-threading, synchronization overhead, and so on. Also code maintenance point of view, one program is much easy to manage in general compare to the multiple copies of the program. Despite these disadvantages, I still like his idea, so free and unique.

When I saw 20 key events for handing four direction's control to speedup dragon five times faster (Figure 2), I was surprised by his idea, especially how freely and creatively he can think. At the same time, I felt the importance of the learning of basic concepts. I wish he will continue to learn without forgetting this thinking way, a free and creative way of thinking.

Figure 2. Using multiple same key events

Comments

Popular posts from this blog

Why A^{T}A is invertible? (2) Linear Algebra

Why A^{T}A has the inverse Let me explain why A^{T}A has the inverse, if the columns of A are independent. First, if a matrix is n by n, and all the columns are independent, then this is a square full rank matrix. Therefore, there is the inverse. So, the problem is when A is a m by n, rectangle matrix.  Strang's explanation is based on null space. Null space and column space are the fundamental of the linear algebra. This explanation is simple and clear. However, when I was a University student, I did not recall the explanation of the null space in my linear algebra class. Maybe I was careless. I regret that... Explanation based on null space This explanation is based on Strang's book. Column space and null space are the main characters. Let's start with this explanation. Assume  x  where x is in the null space of A .  The matrices ( A^{T} A ) and A share the null space as the following: This means, if x is in the null space of A , x is also in the null spa

Gauss's quote for positive, negative, and imaginary number

Recently I watched the following great videos about imaginary numbers by Welch Labs. https://youtu.be/T647CGsuOVU?list=PLiaHhY2iBX9g6KIvZ_703G3KJXapKkNaF I like this article about naming of math by Kalid Azad. https://betterexplained.com/articles/learning-tip-idea-name/ Both articles mentioned about Gauss, who suggested to use other names of positive, negative, and imaginary numbers. Gauss wrote these names are wrong and that is one of the reason people didn't get why negative times negative is positive, or, pure positive imaginary times pure positive imaginary is negative real number. I made a few videos about explaining why -1 * -1 = +1, too. Explanation: why -1 * -1 = +1 by pattern https://youtu.be/uD7JRdAzKP8 Explanation: why -1 * -1 = +1 by climbing a mountain https://youtu.be/uD7JRdAzKP8 But actually Gauss's insight is much powerful. The original is in the Gauß, Werke, Bd. 2, S. 178 . Hätte man +1, -1, √-1) nicht positiv, negative, imaginäre (oder gar um

Why parallelogram area is |ad-bc|?

Here is my question. The area of parallelogram is the difference of these two rectangles (red rectangle - blue rectangle). This is not intuitive for me. If you also think it is not so intuitive, you might interested in my slides. I try to explain this for hight school students. Slides:  A bit intuitive (for me) explanation of area of parallelogram  (to my site, external link) .