The Source for Java Technology Collaboration
User: Password:



   

StarLogo StarLogo

Give the Gift of Learning
by Mike Clark
12/19/2003

Looking for a holiday gift to give your son or daughter that's fun, educational, and has the potential to still be cool well into the new year? Turtles to the rescue! No, I'm not referring to Michelangelo, Donatello, Raphael, and Leonardo, those innocent turtles turned human-sized martial artists by way of radioactive ooze. I'm talking about StarLogo, a dialect of the Logo programming language. That's right, those turtles are back, and this time they've come for the adults too! Whereas Logo is traditionally used to teach geometry through graphics, StarLogo is aimed at exploring and modeling complex systems and emergent behavior. For example, in this article we'll explore a StarLogo simulation that demonstrates how autonomous termites interact to gather wood chips into piles. Indeed, StarLogo offers a playful learning environment that scales to the imaginations of little and big kids alike.

StarLogo is a fun (and free!) present to give your kids. The true gift is one of learning and sharing the learning experience with them. This article will explore StarLogo adventure projects from a termite colony that displays emergent behavior to bumper turtles that familiarize us with the StarLogo environment. These projects demonstrate how kids can play and explore before learning how to program. Finally, avenues for further exploration will be illuminated and in the end, you might be surprised to find yourself playing with StarLogo long after the kids have gone to bed.

Unwrapping StarLogo

StarLogo was developed by a team at the MIT Media Lab and is available for free at education.mit.edu/starlogo. It conveniently runs on the Java platform. The download page includes downloads for Windows, Macintosh, and Unix, in addition to a generic download for any operating system with Java 1.1 or higher installed. The examples in this article were run on Mac OS X.

Once you've downloaded StarLogo, in addition to excellent documentation, you'll also find a sleigh overflowing with ready-to-run projects. The Adventure Projects folder includes a set of projects intended to help beginners get comfortable in the StarLogo environment and introduce them to the principles of modeling. These projects were inspired by the design challenges included in the book Adventures in Modeling (see Resources), an excellent guidebook for parents and educators to help them teach modeling with StarLogo by example. The Sample Projects folder includes intermediate and advanced projects in the categories of biology, graphics, math, physics, and social systems.

Let's get started already by exploring two adventure projects.

Termites Unite!

Termites are amazing little creatures that can move incredible amounts of wood. Indeed, they're quite fun to watch, as long as it's not our wood they happen to be moving. But what makes them truly fascinating is their ability to self-organize and move wood chips into neat piles without a central leader.

We can't possibly model all of the aspects of real termite behavior in our first project, but with StarLogo it's easy to visualize how they gather wood chips into piles. To drop in for a bird's-eye view of a busy colony of termites, double-click the (4) Termites.slogo file in the Adventure Projects folder. StarLogo should start and pop up two windows on the screen -- the Control Center Window and the StarLogo Window -- similar to those in Figure 1.

The Termites project in StarLogo
Figure 1. The Termites project in StarLogo

Ignoring the Control Center Window for now, press the button labeled "go" in the StarLogo Window. The multi-colored termites will start randomly wandering around looking for yellow wood chips. If a termite bumps into a wood chip, and the termite isn't already carrying a chip, then the termite picks up the chip and continues its random wandering in search of another chip. When the termite bumps into another chip, the termite puts down its chip in an empty spot next to the chip the termite had just found. Then the termite jumps away from the pile and goes back to randomly searching for its next chip.

The go procedure in the Control Center Window encapsulates the chip-gathering rules followed by all the termites, expressed in the StarLogo programming language:

    to go
      search-for-chip   ; find a wood chip and pick it up
      find-new-pile     ; find another wood chip
      find-empty-spot   ; find a place to put down wood chip
    end

It might help here to point out that StarLogo is a procedural programming language. Notice that the go procedure calls three other procedures (also shown in the Control Center Window), each of which, in turn, executes a set of StarLogo instructions. The complex termite behavior in the go procedure, therefore, is broken down into three distinct rules encapsulated in simpler procedures. In other words, using procedures, you can build modular and extensible programs in StarLogo.

As a result of the termites following these simple rules, after a short while you'll notice piles of wood chips beginning to form. While the exact pattern varies, over time you should start to see piles similar to those in Figure 2.

Termites self-organize
Figure 2. Termites self-organize to gather yellow wood chips into piles

The edges of the two-dimensional Graphics Canvas are connected to each other, so termites that walk off the right-hand side will reappear on the left-hand side. Figure 2 actually shows one big pile of wood chips "wrapped" around the flattened world.

Use the slider controls to experiment with the termite colony and then press the "setup" and "go" buttons to re-run the simulation. You can even use the Paint and Color Toolbars on the left-hand side of the StarLogo Window to toss in more yellow wood chips while the simulation is running. The StarLogo world is live, so the termites will just happily keep tidying up the place.

The Termites project is particularly interesting because it demonstrates emergent behavior -- following simple, local rules, the termites self-organize to accomplish a relatively complex, global task. That is, no one termite is in charge of instructing all of the other termites how or where to make piles. The pile-building behavior simply emerges from the local interactions between termites going about their business.

StarLogo is designed primarily to help non-experts model and explore complex, dynamic systems. Other examples of "leaderless" systems in our everyday surroundings include flocks of birds, traffic jams, market economies, and social gatherings. StarLogo scales well by also making it easy to create simpler models and learn programming principles along the way.

Big Bumper Turtles

Though mesmerizing to watch, your kids probably won't start modeling the emergent behavior of insect colonies right away. If that was all StarLogo could do, it wouldn't make for a very good gift. ("Gee, thanks, Mom and Dad. I always wanted to model complex, dynamic systems on the computer!") Thankfully, StarLogo includes simpler projects in the Adventure Projects folder, such as Big Bumper Turtles.

Open the project by double-clicking the (3) Big Bumper Turtles.slogo file in the Adventure Projects folder, or by using the File->Open Project menu choice. The Big Bumper Turtles project should appear in windows similar to those in Figure 3.

Big Bumper Turtles
Figure 3. The Big Bumper Turtles project in StarLogo

Get that turtle bumpin' by pressing the "pen-up" button and then the "go" button. The turtle will start moving forward, but bounces off any red, green, or blue obstacles. Depending on the color of the obstacle encountered, the turtle either turns left, right, or does an about face. This simple project demonstrates how turtles can sense changes in their environment and react accordingly.

Now let's experiment with the Big Bumper Turtles simulation. While the simulation is running, press the "clear-graphics" button. The colored obstacles will disappear, but the turtle is still there, moving in a straight, unobstructed path. Add a red, green, or blue obstacle in the turtle's path using the Paint and Color Toolbars on the left-hand side of the StarLogo window. Simply pick the appropriate color from the Color palette, select a paint tool, such as the pencil, and then click in the Graphics Canvas where the turtle is moving to paint the selected color. Now try adding more colored obstacles. In this way, we're able to interact with the simulation before learning to program.

In both of the adventure projects we've played with, you've likely noticed that StarLogo differs from traditional Logo in several important ways. First, unlike Logo, StarLogo enables you to command multiple turtles in parallel. Second, turtles can interact with their surroundings. Those two differences combined allow for interesting turtle-turtle and turtle-world interactions that are essential in modeling decentralized systems.

Now that we've watched StarLogo in action, it's time to introduce the cast of characters in Big Bumper Turtles.

Pages: 1, 2

Next Page » 

View all java.net Articles.

 Feed java.net RSS Feeds