Note, however, that these are examples to learn from, not examples to emulate! The programs are not particularly well-designed as either a systematic test or a useful series of tutorial examples, but until there's anything else they help serve for both. To serve their role as test programs some of these examples deliberately make use of the more obscure and low-level features of the libraries they exercise. Mixed in are examples of many basic code fragments an application might need. So be selective in what you use, and read the comments on each program below.
Most of the programs in this directory use a simple type of object called a "GridTurtle." This type of object is an agent that move around on a two-dimensional grid, always moving in a current direction that it maintains internally. This agent is like a "turtle" of the original Logo system, except that its position is constrained to discrete integer values of its X-Y coordinates, and its direction is always one of the four orthogonal directions north, east, south, or west. The GridTurtle object type is implemented using the module definition conventions of the defobj library, and is itself a defined module that must be initialized by any program.
Initialization of library module. (Swarm applications ordinarily just call initSwarm() which takes care of all needed library initialization.) Basic messages on GridTurtle object.
Tests of Array type. The setInitialValue:, setDefaultMember:, and setMemberBlock: options are each tested by variants of the same basic program.
Tests of List type. grid2 also tests inheritance from a class that implements the List type (not yet supported, but does work). grid2b uses an internal member slot (a special low-level implementation feature) in what is called a List, but should really be an OrderedSet. The messages being used for this are in the process of being changed, and should not be used.
Tests of Map type. grid3b uses an alternate compare function to handle integers rather than id values as keys.
Test of Set and OrderedSet types. The OrderedSet creation in grid4b uses message names that differ from the currently documented interface.
Tests of a collection of allocated objects maintained by a zone. Not officially supported until new Zone implementations are written that perform their own storage allocation rather than directly calling malloc.
Tests of ActionGroup execution independent of any schedule, both by itself and within a swarm.
Tests of schedule execution and schedule merging, using various combinations of absolute, relative, and repeating schedules.
Basic test of schedules running within a simulation swarm that is nested within an observer swarm.
Test of two-level nested swarms using a custom subclass for the swarm. (Normal user subclassing should use the Swarm superclass provided in the swarmobject library.)
Sample application (main program and supporting class) that uses dynamic scheduling. This application is much the same as the mousetrap model of a nuclear chain reaction that is also implemented as a stand-alone application, but it runs outside any user interface framework and links just with the core libraries defobj, collections, and activity.
Variant of mousetraps that schedules actions at subclock divisions of a coarser-grained schedule. Used to test this capability; intended only for specialized use when ordinary time units can't be divided finely enough.
Simple test of basic operations on the String type.
Make file for all programs in the directory. Change the SWARMHOME macro setting at the top to reflect installation location of the swarm libraries relative to the local directory. This make file requires the GNU make program; neither Sun nor other makes are compatible with the GNU-specific conventions used.
Header file that defines the GridTurtle object type. This file is also compiled to publish external definitions for the grid module. Conventions for coding the header file of a library module are not fully documented yet, but this is a working sample.
Initialization of the grid module. Not normally a part of an application program, but included to test module facilities outside of a library. Methods of coding this file are not currently documented, but this is a working sample.
Code for the class that implements the GridTurtle object type. The interface for this type is specified in the file grid.h. Methods for coding classes that implement a type (see module definition conventions for a summary of the differences between types and classes) are not currently documented. The important thing to know is simply that a library implements all the messages declared as part of a type.