Chapter 12. Probing and Displaying the Contents of Swarm Objects

Table of Contents
12.1. What's a Probe?
12.2. Managing Probe Displays
12.3. How to Customize Probe Displays
12.4. Controlling Precision of Display
12.4.1. Global setting of precision
12.4.2. Setting Precision for Individual Probes

Probes allow the user to dynamically interact with the objects in their simulation. As the simulation progresses, the user can observe and adjust the values of the instance variables. Furthermore, the user can cause objects to execute their methods, taking parameter values or input specified by the user during the simulation. generating method calls. The main appeal of this approach is that these interactions are not hardwired into the program code, but occur due to user-generated requests. This interactive process is managed by objects and methods that are, for the most part, hidden from the user. Still, the interaction can be customized easily.

12.1. What's a Probe?

Anyone who has run Heatbugs (or any of the demo programs, for that matter) has seen a probe display. It is a rectangular window that has rows which list attributes of the object being displayed. The data being displayed may be gathered from a high level object, such as the observer swarm or the model swarm, or it may be collected from an individual agent. Almost all Swarm projects have a probe display for the observer and model swarms because starting values for the parameters can be set with those displays. Probe displays for individual agents are typically created during a run by user interaction with the Swarm program (for example, by clicking on a "clickable ZoomRaster", as discussed in the previous section).

The key to this capability is the probe. A probe is an object that can gather information from one object and relay it to other objects, including displays on the screen. Swarm provides two kinds of probes. The Swarm class VarProbe extracts the value of a specific instance variable from an object. The second kind of probe is provided by the MessageProbe class. The MessageProbe. A message probe gives the user the ability to access methods inside an object--to send messages to it, in other words:

Figure 12-1. Combining two VarProbe and one MessageProbes on a ProbeDisplay

There are two main uses for probes: they can be fed into data-collection objects and serve as interfaces to the objects about which data is being collected (thus keeping the data-collection objects as general as possible) - the Averager class, for example, directly subclasses MessageProbe. Or, they can be used in order to generate a GUI to the individual objects in the simulation (the more common usage).

There is a middle-level object between the probe display that appears on the screen and the individual probes. It is the ProbeMap. A probe map is a set that collects up all of the probes for a given object. The probe display does not manage individual probes, but rather it manages probe maps. As we shall see, then, most of the detail in tailoring probe displays ends up in steps that add or remove probes from the probe map.