GUTS Computer Science Concepts

Use of Random Walks

Week 1 2010

Goal: Students will make a simple program that will show how differences in the wiggle size (turning radii) can produce interesting patterns and could lead to differences in a system.

Objectives: Students will review using Starlogo TNG by creating a simple program that uses a Setup, procedure, forever and random.

Students can work on their own pace if they have strong TNG experience or you can guide them step-by-step through the activity and leaving an open ended exploration at the end.

Directions:

1.  Open Starlogo TNG, start with a new project

2.  Bring out a Setup block and the ‘create’ block. Start with a population of 1 turtles. These turtles will be a red color, should have their pendown and be scattered.

3.  Make a procedure using a Procedure block. Call this Wiggle1. This Wiggle1 procedure will have the turtles moving left and right a random 10 degrees then going forward 1 step.

4.  Connect the Wiggle1 procedure block to the Forever and test how it is working.

5.  Create a second breed; connect the ‘create’ block to the setup, with a new population of 1, blue color, pendown and scatter them.

6.  Make a second procedure called Wiggle2. This Wiggle2 procedure will have a random 50 degrees for their left and right. Attach the procedure to the Forever and test it.

7.  Make a third breed and a wiggle procedure with an even larger turning radius (up to 360 degrees).

8.  The final code is pictured below. Test the program and allow students to make changes to show more about Random Walks.

Discussion Questions:

What differences do you see?

How could the different wiggle sizes be used in a model? When might it be useful to have different wiggle sizes?

Extension:

Make a slider for the wiggle size. (hint: use a global variable and substitute in this variable for the numbers after the random in the wiggle procedure).