106 3 ABMs Using Repast and Java
3.3.6 Creating a Display
Although we have completed the implementation of the Game of Life model, there
will be nothing to see unless we create a display for it. The Repast environment
makes it remarkably easy to create agent displays, and this is one of its major ad-
vantages over building a model completely from scratch. We will start by describing
the basic steps in setting up a display, and then look at some of the customizations
that are necessary to obtain a display that matches the particular requirements of the
Game of Life model.
Running a model opens a new GUI window that contains a panel, the Scenario
Tree. This is an area where runtime-related functionality is defined, such as the
form of any visualization, charting, and model output. A model display is created
by right-clicking over the Displays icon and selecting Add Display. The display can
be named, and either a 2D or 3D display selected. We require a 2D display for the
Game of Life. It is necessary to indicate which of potentially many projections is
to be displayed. As we only have a single projection named World, we select that
name and click on the right-pointing arrow to transfer the name from the left to
the right column. Clicking Next takes us to a dialog where we can indicate which
agents are to appear in the display. The score file is used to supply the list here. We
named two agents but ModelInitializer is really a pseudo-agent and not to
be displayed so we click on its name and select the red minus symbol to delete it
from the list. That leaves just Agent. At this stage, we will do nothing further here,
but note that there is a Style Class listed named DefaultStyle2D. This class is
the one from the Repast API that will be used to provide the visualization of the
Agent objects in the display. As we shall see, this default class is not actually able
to provide the visualization that we want, but it will do for the time being. Selecting
Next takes us to a further dialog window requesting details of how the grid should
appear in the display. The default values are sufficient. Selecting Next takes us to
a dialog for scheduling. Again, the default values are sufficient. Selecting Finish
completes the creation of a display. At this stage it is important to save the Scenario
Tree, otherwise the choices we have just made will be lost. Select either the File →
Save or the disk icon in the GUI window.
The model is initialized by selecting Run →Init or the on/off icon. A grid should
appear in the rightmost panel. This is the basic display we have just defined but with-
out any agents yet. The display can be moved by selecting it with the right mouse
button and dragging. At the top right corner of the display area is the Tick Count,
currently set to 0.0. Select either the Run → Step menu item or the double-arrow
Step Run icon. Do this twice so that the tick count displays 1.0. The grid should
be filled with pink circles (Fig. 3.11). Each circle is a display of an agent using
the DefaultStyle2D class. If the model is stepped once more the tick count
moves on to 1.5 but the display does not change at all. Further stepping produces
no changes, apart from the incrementation of the tick count by 0.5 each time. These
particular increments are the result of the scheduling settings we chose when defin-
ing the agent’s behavior.