Getting Started
1. Introduction StarLogo is a programmable modeling environment for exploring the behaviors of decentralized systems, such as bird flocks, traffic jams, and ant colonies. It is designed especially for use by students. In decentralized systems, orderly patterns can arise without centralized control. Increasingly, researchers are choosing decentralized models for the organizations and technologies that they construct in the world, and for the theories that they construct about the world. But many people continue to resist these ideas, assuming centralized control where none exists--for example, assuming (incorrectly) that bird flocks have leaders. StarLogo is designed to help students (as well as researchers) develop new ways of thinking about and understanding decentralized systems. StarLogo is an extension of the Logo programming language. With traditional versions of Logo, you can create drawings and animations by giving commands to a graphic "turtle" on the computer screen. StarLogo extends this idea by allowing you to control thousands of graphic turtles in parallel. In addition, StarLogo makes the turtles' world computationally active: you can write programs for thousands of "patches" that make up the turtles' environment. Turtles and patches can interact with one another. For example, you can program the turtles to "sniff" around the world, and change their behaviors based on what they sense in the patches below. StarLogo is particularly well-suited for modeling complex decentralized systems--systems which traditionally have not been available to people without advanced mathematical or programming skills. This document provides a short introduction to the Java version of StarLogo. It describes the basic features of StarLogo, and it suggests initial activities for using and learning StarLogo. At the end are pointers to other documents that provide a more complete description of the StarLogo language. 2. The Cast of Characters StarLogo includes three main types of "characters": The StarLogo interface consists of several main windows:
Control Center window. The Command Center area of the Control Center window is where you type commands for StarLogo. You may run a command again by moving the cursor to that line and pressing return. The Procedures area is where you write your own StarLogo procedures. By clicking back and forth between "Turtle" and "Observer" you can distinguish between those commands which are specific to turtles and those which can only be executed by the observer. Refer to the Reference Manual for a more complete description of the different command types available to each StarLogo character. Turtle Monitors. If you double-click on a turtle in the Graphics area, a Turtle Monitor will appear, showing the turtle’s variables, both standard and user-defined, and their values. The values update in real-time as your StarLogo project is running. You can also use the Turtle Monitor to directly change the value (state) of the variable. 4. Sample Projects Probably the best way to start learning about StarLogo is to play with some sample projects. The sample-projects folder includes a diverse collection of StarLogo projects. Try them! Each sample project comes with a set of procedures (some combination of turtle procedures and observer procedures), a set of interface objects such as buttons and sliders (in the Interface area), and a set of explanatory notes (in the Information window, accessible through the Control Center menu bar). Make sure you read the notes and instructions in the Information window. These notes explain ways to use the project, ideas underlying the project, and suggestions for further explorations. The sample projects are:
These projects can all be accessed from the Sample Projects page. 5. Creating Your Own StarLogo Project This section guides you through a sample session with StarLogo, showing you how to create a new StarLogo project. As an example, it describes how to create a "paintbrush" consisting of several hundred StarLogo turtles. To start a new project, choose New from the
File menu of the Control Center. Make sure you are in the
Observer Command Center and type (pressing the return key after each command): Next, switch to the Turtle Command Center and type the following
commands (pressing return after each command): Now, switch back to the Observer command center and type
It might be useful to have some buttons that allow you to control the "turtle paintbrush" interactively. To create a new button, select the button tool from the Main Toolbar, then click in the Interface area and "drag out" a rectangle. A dialog box appears. In the Logo Instruction field, type fd 1. Be sure that the "Turtle" and not the "Observer" item is checked. Then click OK. Your new button appears. Whenever you click the button, all of the turtles move forward one step. There are two types of StarLogo buttons. You just created a once-button: when you click the button, it executes its instruction once. Let's change the fd 1 button to the other type of button: a forever-button. Select the fd 1 button (by control-clicking on it, or by dragging a rectangle around the button). Then double-click on the selected button. The button's dialog box reappears. (You can also get the button's dialog box by single-clicking on the button with the button tool.) Check the forever box, then click OK. Notice the looping pair of arrows on the face of the button. These looping arrows indicate that the button is a forever-button. Click on the fd 1 button. The turtles execute the fd 1 instruction again and again, so the circle keeps moving forward. Forever-buttons run in the "background": you can execute other instructions in the command center while forever-buttons are running. Try typing rt 45 in the Turtle Command Center. The circle of turtles veers to the right. Switch to the Observer command center and type cg: the graphics clear but the turtles continue to draw. To stop the turtles, click on the fd 1 forever-button. You might want to add some additional buttons. For example, make a new forever-button with the instruction rt 5. Click on both the fd 1 button and the rt 5 button. (StarLogo allows forever buttons to run in parallel.) The turtles all draw circles. By clicking the rt 5 button on and off selectively, you can move the turtles around the screen. It might be useful to add cg button so that you can easily clear the graphics. The cg button should be once-button, not a forever-button, since you don’t want StarLogo to continue clearing the graphics repeatedly. In addition, since cg is an observer command, you should be sure to check "Observer" next to the Logo Instruction field when creating your button. You might also want to add once-buttons to lift up the turtles’ pens (pu) and to put the pens down (pd). (Pen up and pen down are both turtle commands, so check "Turtle" next to the Logo Instruction field.) If you plan to save the paintbrush project, it would be
a good idea to write a "setup" procedure so that you can recreate the
paintbrush easily in the future. First, go to the Observer Procedures
window. Type: This procedure adds a new word to the list of commands which the observer knows. First, the observer clears the Graphics area (ca stands for clear all). Then, the observer creates 280 turtles. Next, the observer asks the turtles to perform the commands listed inside the square brackets []. The ask-turtles command in effect transfers control from the observer to the turtles--just like when you switch from the Observer Command Center to the Turtle Command Center and back. After the square brackets are closed, the procedure returns control to the observer. Once you’ve written the procedure, go back to the Interface area and make a once-button whose Logo Instruction is the command setup. When you click the setup button, StarLogo reinitializes the paintbrush. Here are some other things to try with the paintbrush project: Make a slider called "turn", then change the rt 5 button to rt turn. With the new slider, you can more interactively control the turning radius of the turtles. Add buttons for changing the colors of the turtles. For example, create a forever-button with the instruction setc color + 1 Create new procedures and buttons that allow you to shrink and expand the circle as it moves. (Warning: This is not trivial! Hint: Each turtle needs to “remember” its original heading.) If you want to save the paintbrush project, select Save from the File menu in the Control Center menu bar. 6. Other StarLogo Documentation We hope that this document helped you get started with StarLogo.
There are several other documents that provide more detailed descriptions
of StarLogo: |