## Sunday, August 18, 2013

### Help Getting Started with Scratch

I will be teaching a mathematics class this Fall for middle and high school math teachers. The course requires that students do a bit of programming in the Scratch environment. To smooth their entry into Scratch,  I have written three Getting Started with Scratch  documents.
The first document guides the reader through the steps of building a script that draws a square with a side length of 100 steps. This introduces the blocks menu and the mechanics of connecting blocks together to build a script.
The second document describes how to create variables, sliders, and how to set the minimum and maximum values in a slider. The size of the square is now under variable control.
The third document helps the reader build a script that will draw any regular polygon. In a regular polygon the side lengths are equal. A slider controls the number of sides and again, the side length is controlled by a slider.
The relationship between the number of sides and the turn angle for a regular polygon of n sides requires a bit of mathematical analysis.

You may request any or all of these documents—in PDF format— by sending an email .
Getting Started with Scratch – Part 1
Getting Started with Scratch – Part 2
Getting Started with Scratch – Part 3

## Thursday, August 8, 2013

### A Simple Model of Diffusion

This Scratch project is an over-simplified look at the physical process that occurs when a drop of ink is placed in a very thin layer of water.
The ink molecules perform random walks. Over time, the molecules drift from the center and diffuse throughout the water.
In the following short video, I demonstrate how to add a drop of red food coloring to a very thin layer of water and then watch as the coloring diffuses in a near perfect circle. Several billions of red-colored particles are involved in the video and the statistics that govern the random walks of such a large number of particles accounts for the circular diffusion.
The following Scratch project is my first look at 'cloning', available in the new 2.0 version of Scratch. Years ago I did this same project in Starlogo

Starlogo has a crt X command (create turtles X) that commands the X number of turtles to execute (in parallel) the same procedure. If you 'See inside' to look at the code, I think you will see that  I used 'clone sprite 1' to the same effect in this project.
Here's a very short video of the Scratch project in action.
The maximum number of particles I can clone in Scratch 2.0 is 300 so there aren't the billions of particles in the Scratch simulation that there are in the actual food coloring demonstration.
Still, even with such a low number of particles, one can see the diffusion away from the center and the roughly circular shape emerging from the random walks.
This is the link to the project.
The ability to 'clone' a sprite means only one script has to be written and it controls all of the clones!
Notice that this project is an extension from the one-dimensional random walk on the integer number line (see previous post) to the the two-dimensional plane.