Cast Of Characters
A StarLogo world is made up of three characters: turtles, patches, and the
observer. Turtles live on a grid of active patches, and both can be controlled by the observer. This world provides fertile ground for interesting turtle-turtle and turtle-world interactions.
Turtles
A turtle is anything that moves around on the Graphics Canvas. Turtles can appear as any shape, such as a termite or an automobile. You can move a
turtle around the Graphics Canvas by dragging it with the mouse. Just for fun,
see if you can relocate the bumper turtle.
Each turtle has a set of internal state variables that can influence how it
looks or behaves. Unless you've already stopped the Big Bumper Turtles
simulation, the button labeled "go" will still be depressed. Press
the "go" button again to stop the simulation. Double-clicking on any
turtle shape will pop a Turtle Monitor window similar to the one in Figure 4.

Figure 4. Monitoring a turtle's state
Notice that this turtle has a predefined set of variables, including its unique
who number. A turtle's who number is useful as its
call sign for communication with other turtles. Think of this as Whoville; this turtle is Cindy Lou Who.
Change the turtle's color by setting its color variable to
red and watch the on-screen effect. With a bit of programming,
turtles can also be assigned custom variables (e.g. energy) to modify their behavior.
Notice also that you can command this turtle by typing StarLogo commands in the Command Center text area at the bottom of the Turtle Monitor window. Type the following StarLogo commands to instruct this turtle to move ahead a distance of 2 patches and then turn right 90 degrees:
fd 2
rt 90
Perhaps you found those commands to be a bit too cryptic. They use the shorthand notation consistent with the coding style of the adventure projects. If you'd prefer to be more expressive (it's never too early to instill good coding style!), the following StarLogo commands do the same thing:
forward 2
right 90
We'll learn how to command all turtles in one fell swoop a bit later.
Patches
The turtles live on an invisible grid of patches. As a turtle moves around, it can interact with the patches. Each patch can contain an arbitrary amount of information to be "sniffed" by turtles. In the termites project, for example, a termite knows it has bumped into a wood chip by asking if the patch underneath the termite is yellow. The termite then picks up the wood chip by updating the patch's color to black.
Patches can also execute commands to do things like grow turtle food or sprout new turtles. Double-click on any empty patch on the Graphics Canvas to pop up a Patch Monitor window similar to the one in Figure 5.

Figure 5. Commanding a patch
Just as we sent commands to a specific turtle in the Turtle Monitor window, we can command a specific patch by typing in the Command Center text area at the bottom of the Patch Monitor window. Type the following StarLogo command to ask the selected patch to create (sprout) a turtle that sets its color to green and moves forward 2 patches:
sprout [setcolor green fd 2]
The syntax of this StarLogo patch command bears explanation here. The sprout command first creates a turtle and then sends the list of commands between the square brackets to the new turtle. Notice the two turtle commands aren't explicitly separated. That is, separation of multiple commands in a list is implicit.
Observer
The observer is the omniscient character watching over the StarLogo world. At the beginning of a simulation, the observer generally sets the stage by
creating turtles and configuring patches. The observer can then ask both
turtles and patches to perform certain commands, but the observer doesn't
necessarily dictate how the newly-created turtles go about their work. That is,
the observer is not intended to be the leader of turtles.
Poking and prodding turtles is good, clean fun. Let's take a closer look at
interacting with Big Bumper Turtles.
Interfacing With The Characters
User interface components -- buttons, sliders, monitors, and graphs -- can be
added anywhere in the white area around the Graphics Canvas. Use the Toolbar
at the top of the StarLogo Window to create new interface components for the
project.
Commanding All Turtles
To see what really happens when a button is pressed, select the "go"
button (on Windows, press the Control key and double-click; on a Mac, press the Shift key and double-click). You should see a window like the one in Figure 6.

Figure 6. The "go" button calls the go procedure
The StarLogo instruction associated with this button happens to be called
"go", though the instruction name need not match the button name.
StarLogo doesn't define go as a primitive command. Rather,
go is a procedure -- a collection of other StarLogo commands
(and/or procedures) -- written specifically for this project. Notice that the
"Turtle" radio button is selected. This means that the
go procedure is intended to be run by all the turtles, not the
observer. Turtles and the observer respond to different commands, so you have to tell StarLogo which character should run the command.
To view the StarLogo commands used in the go procedure, select the
Turtle tab in the Control Center Window. You'll see the Turtle Command Center pane at the top and the Turtle Procedures pane at the bottom, as shown in Figure 7.

Figure 7. The Turtle Command Center commands all turtles
In the Turtle Procedures pane, you'll find the definition of the
go procedure that encapsulates the commands followed by bumper turtles.
In the Turtle Command Center pane, you can type StarLogo commands or the name
of an existing turtle procedure to be run by all turtles. For example, even while the Big Bumper Turtles simulation is running, you can turn of all the turtles red by typing the StarLogo command:
setcolor red
The "Commands" page of the documentation describes all of the turtle commands.
Feel free to experiment with some turtle commands. Notice that any turtle
command you type in the Turtle Command Center pane is run by all of the
turtles.
Commanding The Observer
The observer has the power to create turtles and ask them to run commands.
Select the Observer tab in the Control Center Window to command the
observer. You'll see the Observer Command Center pane at the top and the
Observer Procedures pane at the bottom, as shown in Figure 8.

Figure 8. The Observer Command Center controls the observer
Check out the setup procedure in the Observer Procedures pane.
This observer procedure is called when the
"setup" button is pressed. It's no magic; edit the
"setup" button to see for yourself.
Notice that the setup procedure includes the following
StarLogo command:
crt number
The crt command (shorthand for the create-turtles
command) creates the specified number of turtles,
in this case the number indicated by the number variable.
The number variable is set by a slider control.
Select the "number" slider in the StarLogo Window (on Windows, press the Control
key and double-click; on a Mac, press the Shift key and double-click)
and you should see a window like the one in Figure 9.

Figure 9. The "number" slider controls the number variable
Because the number variable controlled by the "number"
slider is used in the observer's setup procedure, changing the slider's
value only takes effect when the "setup" button is pressed.
Now type the following StarLogo command in the Observer Command Center to
command the observer to create four new bumper turtles:
create-turtles 4
The newly born turtles start out as a pile in the center patch of the Graphics
Canvas. If the simulation is already running, the turtles will immediately
begin moving forward in different directions while following the instructions
in the go procedure.
The "Commands" page of the documentation describes all of the observer commands.
Try a few commands and see what happens. The turtles will love you for it!
Teaching Programming Gradually
We've seen glimpses of the StarLogo programming language in the Command Center Window. It's a full-featured programming language with a rich set of commands, including:
- Conditional expressions
- Repetition constructs
- List processing
- Math commands
- Procedures
- Recursion
But as cool as the language might be for us geeks, I wouldn't expect the
kiddies to have aspirations of being StarLogo programmers, at least not
initially. On the other hand, kids might have their own ideas for making
the simulation cool for them. ("Daddy, can we make all the turtles
jump?") So how do you let them create and alter worlds without teaching them the language?
I'd recommend you start by helping them choose buttons and sliders as
interfaces to the world. Then you can write the StarLogo procedures that bring
life to the controls. For example, you can create a button associated with the
StarLogo command jump 5. If and when they express more interest
in how it works, you can gradually introduce them to the language.
Typing individual commands into the Control Center Window is another fun way to
experiment. Seeing the visual effect of a command is a powerful learning aid. And as young programmers start using multiple commands together repeatedly, you can show them how to make a procedure. Style points for refactoring!
Above all else, encourage them to experiment on their own without worrying about making mistakes. Debugging, after all, is an essential part of the learning process.
Further Exploration
The projects included with StarLogo offer a lot to explore. Once you've opened
a project, use the Windows->Info Window menu choice to learn more about it.
As further exploration, you may enjoy experimenting with the following
adventure projects, as they demonstrate StarLogo features not covered in this article:
Shiny Happy Turtles:
Demonstrates the use of a custom turtle variable (happiness) that increases and
decreases proportional to slider values as turtles interact with
"school" and "cinema" patches. And turtles sharing the same patch interact to double their happiness!
Castle Invasion:
Turtles search for four code words in order to invade the castle. Using the
grab command, you can modify this project so that turtles
conspire -- communicating with their who number -- to hasten the invasion.
Gotya:
Demonstrates how turtles can "flock" by a turtle following any other
turtle.
Traffic:
A traffic jam simulation that uses turtle breeding to give
different sets of turtles their own unique behaviors.
Predators Prey Grass:
An advanced predator-prey model.
I found reading and modifying the code in the sample projects to be a
productive way to learn the power of the StarLogo language.
Once you've crafted a spiffy new StarLogo project of your own, you can make it
available on the Web for the world to behold. Yep, since StarLogo runs on
Java, it can also run as an applet. Just save the project using the
File->Save Project As Web Page menu choice. You'll need to place the
resulting .html file, and the existing <project>.slogo and
starlogo.jar files in the same directory. I wasn't able to
convince a browser on the Mac to run a StarLogo applet, but Netscape on a
PC worked just dandy.
NetLogo
I chose StarLogo for this article primarily because it includes elementary
adventure projects. If you're looking for more advanced models and features, I
recommend you give NetLogo a whirl. NetLogo was inspired by StarLogo, and
shares many of the same features, but offers significant new features and a
redesigned user interface. And NetLogo's model library is quite extensive,
including adult projects for after the kids have gone to bed: Tetris, Frogger,
and even Pac-Man. I'll bet you never thought of Pac-Man as an emergent systems
model before!

Figure 10. NetLogo has an extensive model library ;-)
Summary
In this article, we've covered a lot of turtle ground. And yet, we've just
barely scratched the surface of the lush StarLogo world. We've seen how StarLogo can scale from one turtle moving forward and making basic turns to hundreds of turtles following simple rules to simulate complex behavior. We've learned how to interact with the StarLogo world using controls. And along the way, we got a taste of the simple, yet powerful, StarLogo programming language.
StarLogo is a open-ended environment that allows kids of all ages to create,
explore, and learn while having fun. This holiday season, give a gift that
keeps on giving -- learn StarLogo with your kids. I hope you have a lot of fun
together. Cowabunga, Dudes!
(Based on interest in this article, it may become the first in a series of articles. I'd love to hear back from you regarding the usefulness of this article and what you might be interested in learning next.)
Resources
StarLogo home page
StarLogo downloads, extensive documentation, a tutorial, and more.
Adventures in Modeling: Exploring Complex, Dynamic Systems with StarLogo
Vanessa Stevens Colella, Eric Klopfer, and Mitchel Resnick,
Teachers College Press, 2001.
An educator's guidebook to the adventure projects distributed with
StarLogo, complete with group activities that simulate emergence,
StarLogo modeling challenges, and student handouts for each challenge.
Emergence: The Connected Lives of Ants, Brains, Cities, and Software
Steven Johnson, Scribner, 2002.
Explores decentralized, emergent systems in our everyday surroundings.
NetLogo home page
An extended version of StarLogo (also free and written in Java) that
includes new features, a redesigned user interface, and a plethora of
advanced models.
The Logo Foundation
Links to Logo resources