Chapter 6. The Swarm Tutorial: Reprise

Table of Contents
6.1. Tutorial Progression
6.2. What Are You Supposed to Learn from the Tutorial?
6.3. After the Tutorial: What now?

Most Swarm users share terminology and perspective that allows them to communicate with each other about modeling projects. These shared elements are first introduced to most users in the Swarm Tutorial, a series of exercises prepared by Christopher Langton. The Tutorial exercises are distributed on the SDG web site in the swarmapps package.

ImportantDo Your Homework!

There is no way to get anywhere with Swarm unless you are willing to get your hands dirty. The Swarmapps package provides some examples of swarm programs that deserve study. That package also provides the bug tutorial, a series of exercises that all Swarm users must read, edit, compile, study, test, explore, and investigate.

If you are new to Swarm, and don't know much about programming in general, and possibly less about Objective-C in particular, the tutorial series is a perfect place to start. Even if you are an expert programmer, a study of the tutorial is the right place to start. Many of key terms in Swarm model building are introduced in the tutorial and there is simply no substitute for a careful analysis of the material.

WarningJava Stops Here!

From hereon in, the Guide will only refer to examples in Objective C. The Guide is in the process of being updated to include Java examples of the basic Swarm concepts covered in the following chapters. That said, although many of the concepts described are described in Objective C terms, most of the concepts carry over intact into the Java context, and (mostly!) only differ in fairly trivial syntactical ways, so it possible that Java users can benefit from the following sections

6.1. Tutorial Progression

The tutorial gameplan is as follows: Begin with a program written in C that is little more than a basic "hello world" program about a "bug" creature that wanders. Through a series of steps which first introduce Objective-C and then the Swarm hierarchical modeling approach, one can gain a good grounding in Swarm modeling.

The tutorial outline is as follows:

  1. simpleCBug. Simple C code about a bug

  2. simpleObjCBug. Bug is now Objective-C class

  3. simpleObjCBug2. Adds FoodSpace object

  4. simpleSwarmBug. Introduces the ModelSwarm as the central organizing element. From the class Swarm in the Swarm library, this code creates subclass ModelSwarm, and the instance of ModelSwarm is created and called modelSwarm (in main.m). In the class ModelSwarm, one finds an implementation of the Schedule class, the workhorse that keeps the Swarm train moving on time.

  5. simpleSwarmBug2. Introduces the bugList, an instance of the List class, and illustrates some ways in which simulations with many agents can be organized.

  6. simpleSwarmBug3. Introduces the Swarm class ObjectLoader that the can grab data from a file and read it into an object (in this case, the modelSwarm).

  7. simpleObserverBug. Subclasses from the Swarm class SwarmGUI to create a new class ObserverSwarm, an instance of which is created and called observerSwarm. This is the first example with a complete Swarm hierarchy which begins with main.m and translates actions from ObserverSwarm to ModelSwarm to individual agents.

  8. simpleObserverBug2. This example adds probes that allow users to click on graphics to reveal information inside them.

  9. simpleExperBug. Introduces the possibility that a simulation might be run over and over in "batch" mode while the graphical interface reports summaries of the runs to the user.